[sigc] libsigc++ on G++ 3.2



Hi,

I managed to compile libsigc++ 2.0.14 on G++ 3.2 using the patch below.
Basically, I just uncommented the declaration of inner class, as suggested
in the comments.  However, I propose to make it somewhat more automated and
based on whether a preprocessor macro is defined.

Currently, WRAP_IS_BASE_CLASS_ is never defined, since I couldn't quite
understand `sigc++config.h.in'.  However, it should be possible to determine
G++ version like this (modified from GNU Go source, where I added this some
time ago):

AH_TEMPLATE([GXX_MAJOR_VERSION], [Define to G++ major version.])
AH_TEMPLATE([GXX_MINOR_VERSION], [Define to G++ minor version.])

if test "$GXX" = "yes"; then

  dnl M4 escaping of brackets
  [GXX_VERSION=`$CXX --version | sed '1!D;s/^[^0-9]*\([0-9]\+\.[0-9]\+\).*$/\1/'`
   GXX_MAJOR_VERSION=`echo $GXX_VERSION | sed 's/^\([0-9]\+\).*$/\1/'`
   GXX_MINOR_VERSION=`echo $GXX_VERSION | sed 's/^[0-9]\+\.\(.*\)$/\1/'`]

else
  GXX_MAJOR_VERSION=0
  GXX_MINOR_VERSION=0
fi

So that later it is possible to do sth. like

#define WRAP_IS_BASE_CLASS_  (GXX_MAJOR_VERSION == 3 && GXX_MINOR_VERSION == 2)

By the way, as far as I know `friend class x;' itself serves as a forward
declaration, so that an additional `class x;' is redundant.

Paul


P.S. It seems that `type_traits.h' gets installed, so this approach
     will not work...  I dunno.  Maybe you could have a single line
     header file with definition of WRAP_IS_BASE_CLASS_ and then
     install it too.  It could be generated by `configure' script.
     If you are interested, I can have a stab at this.


--- /home/paul/type_traits.h.orig	2005-06-11 19:54:09.000000000 +0300
+++ /home/paul/libsigc++-2.0.14/sigc++/type_traits.h	2005-06-11 20:02:20.000000000 +0300
@@ -99,25 +99,40 @@ private:
 
   //Allow the test inner class to access the other (big) inner class.
   //The Tru64 compiler needs this. murrayc.
-  //struct test;
-  //friend struct test;
+  //struct internal;
+  //friend struct internal;
+
+#if WRAP_IS_BASE_CLASS_
+
+  //Some compilers, e.g. G++ 3.2, require these pseudo-functions to be
+  //wrapped up.  Else they give errors.
+  struct internal
+  {
+    static big  is_base_class_(...);
+    static char is_base_class_(typename type_trait<T_base>::pointer);
+  };
+
+public:
+  static const bool value =
+    sizeof(internal::is_base_class_(reinterpret_cast<typename type_trait<T_derived>::pointer>(0))) ==
+    sizeof(char);
+
+#else  // not WRAP_IS_BASE_CLASS_
 
   //The AIX xlC compiler does not like these 2 functions being in the inner class.
   //It says "The incomplete type "test" must no be used as a qualifier.
   //It does not seem necessary anyway. murrayc.
 
-  //struct test {
-  //For gcc 3.2, try uncommenting the "struct test" inner class declaration, and also using a test:: prefix below.
-  //If it works then submit a patch. A new configure-time compiler-ability check would be even better. murrayc.
-    static big  is_base_class_(...);
-    static char is_base_class_(typename type_trait<T_base>::pointer);
-  //};
+  static big  is_base_class_(...);
+  static char is_base_class_(typename type_trait<T_base>::pointer);
 
 public:
   static const bool value =
     sizeof(is_base_class_(reinterpret_cast<typename type_trait<T_derived>::pointer>(0))) ==
     sizeof(char);
 
+#endif // not WRAP_IS_BASE_CLASS_
+
   void avoid_gcc3_warning_(); //Not implemented. g++ 3.3.5 (but not 3.3.4, and not 3.4) warn that there are no public methods, even though there is a public variable.
 };
 





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]