Hello,

naresh wrote:
I found the solution It was very simple but still does not understand why it generate errors.

I'm happy to hear you found a solution. As for why you see an error in the first place, I really don't know, I don't think there is something wrong with the code, but the compiler seems to not like it :-/

In Logger class it has operator for template conversion to std::ostream. I simply remove address in macro and then it just compile fine.

like here Old code was like this
#define SLOG     \
static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_LOG, OSG_LOG_MODULE, __FILE__, __LINE__)))

and i replaced like this

#define SLOG     \
static_cast<std::ostream>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_LOG, OSG_LOG_MODULE, __FILE__, __LINE__)))


So is there any problem with OSG::LogLock Operator problem that returns std::ostream ?

yes, this can cause problems as the stream object is of a type derived from std::ostream (OSG::Log to be precise) and returning just std::ostream "slices" the added parts away.
A different solution would be to add a function
std::ostream &LogLock::getStream(void)
that returns a reference to the stream object, the attached patch implements that.
Hopefully the intel compiler likes this variant.

        Hope it helps,
                Carsten
Index: Source/Base/Base/OSGLog.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/Base/Base/OSGLog.h,v
retrieving revision 1.17
diff -u -r1.17 OSGLog.h
--- Source/Base/Base/OSGLog.h	11 Apr 2008 11:49:03 -0000	1.17
+++ Source/Base/Base/OSGLog.h	2 Feb 2009 14:57:11 -0000
@@ -450,7 +450,8 @@
     /*! \name                   Class Specific                             */
     /*! \{                                                                 */
 
-    inline operator std::ostream &();
+    inline               operator std::ostream &(void);
+    inline std::ostream &getStream              (void);
 
     /*! \}                                                                 */
     /*===========================  PRIVATE  ===============================*/
@@ -487,35 +488,35 @@
 */
 
 #define SLOG     \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_LOG,     OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_LOG,     OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief SFATAL
     \ingroup GrpBaseLog
 */
 
 #define SFATAL   \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_FATAL,   OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_FATAL,   OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief SWARNING
     \ingroup GrpBaseLog
 */
 
 #define SWARNING \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_WARNING, OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_WARNING, OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief SNOTICE
     \ingroup GrpBaseLog
 */
 
 #define SNOTICE  \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_NOTICE,  OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_NOTICE,  OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief SINFO
     \ingroup GrpBaseLog
 */
 
 #define SINFO    \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_INFO,    OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(true, OSG::LOG_INFO,    OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 
 /*! \brief PLOG
@@ -523,35 +524,35 @@
 */
 
 #define PLOG     \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_LOG,     OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_LOG,     OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief PFATAL
     \ingroup GrpBaseLog
 */
 
 #define PFATAL   \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_FATAL,   OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_FATAL,   OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief PWARNING
     \ingroup GrpBaseLog
 */
 
 #define PWARNING \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_WARNING, OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_WARNING, OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief PNOTICE
     \ingroup GrpBaseLog
 */
 
 #define PNOTICE  \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_NOTICE,  OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_NOTICE,  OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 /*! \brief PINFO
     \ingroup GrpBaseLog
 */
 
 #define PINFO    \
-    static_cast<std::ostream&>(OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_INFO,    OSG_LOG_MODULE, __FILE__, __LINE__)))
+    OSG::LogLock(OSG::osgStartLog(false, OSG::LOG_INFO,    OSG_LOG_MODULE, __FILE__, __LINE__)).getStream()
 
 
 // C interface, because it can be compiled away
Index: Source/Base/Base/OSGLog.inl
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/Base/Base/OSGLog.inl,v
retrieving revision 1.9
diff -u -r1.9 OSGLog.inl
--- Source/Base/Base/OSGLog.inl	11 Apr 2008 11:49:03 -0000	1.9
+++ Source/Base/Base/OSGLog.inl	2 Feb 2009 14:57:11 -0000
@@ -242,7 +242,12 @@
     osgLogP->unlock();
 }
 
-inline LogLock::operator std::ostream &()
+inline LogLock::operator std::ostream &(void)
+{
+    return _os;
+}
+
+inline std::ostream &LogLock::getStream(void)
 {
     return _os;
 }
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to