I have a build of glib-2.46.2 on HP-UX/PA and HP-UX/IA that has constructors working. Getting it to work on HP-UX/PA wasn't too difficult but HP-UX/IA was a bit more involved. This email is to discuss the solution on HP-UX/IA. Support for constructors currently requires the help of the preprocessor, using glib/gconstructor.h. This works ok on HP-UX/PA but not HP-UX/IA. According to the HP-UX/IA compiler documentation: The #pragma directive is ignored by the preprocessor, and instead is passed on to the HP aC++ compiler.
So, on HP-UX/IA, G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS cannot work because the HP-UX C compiler passes the raw string to #pragma. Is there a cleaner solution than adding something like: #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor) +#elif defined(__hpux) && defined(__ia64) +#pragma INIT "glib_init_ctor" #endif I've attached my current patch. -- albert chin (ch...@thewrittenword.com)
Index: glib/gconstructor.h =================================================================== --- glib/gconstructor.h.orig 2016-02-28 14:04:14.000000000 +0000 +++ glib/gconstructor.h 2016-02-28 20:26:42.874644675 +0000 @@ -102,6 +102,32 @@ #define G_DEFINE_DESTRUCTOR(_func) \ static void _func(void); +#elif defined(__hpux) + +#define G_HAS_CONSTRUCTORS 1 + +/* + According to the aCC documentation, "The #pragma directive is + ignored by the preprocessor, and instead is passed on to the + HP aC++ compiler. So, using a #define to define the #pragma- + specific incantation based on the compiler will not work on + HP-UX/IA (HP-UX/PA works fine). + */ +#ifndef __ia64 +#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1 +#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1 + +#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \ + INIT #_func +#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \ + FINI #_func +#endif + +#define G_DEFINE_CONSTRUCTOR(_func) \ + static void _func(void); +#define G_DEFINE_DESTRUCTOR(_func) \ + static void _func(void); + #else /* constructors not supported for this compiler */ Index: glib/glib-init.c =================================================================== --- glib/glib-init.c.orig 2015-11-06 18:12:04.000000000 +0000 +++ glib/glib-init.c 2016-02-28 20:27:20.298286762 +0000 @@ -278,6 +278,8 @@ #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor) +#elif defined(__hpux) && defined(__ia64) +#pragma INIT "glib_init_ctor" #endif G_DEFINE_CONSTRUCTOR(glib_init_ctor) Index: gobject/gtype.c =================================================================== --- gobject/gtype.c.orig 2015-11-06 18:12:04.000000000 +0000 +++ gobject/gtype.c 2016-02-28 20:27:18.521472422 +0000 @@ -4481,6 +4481,8 @@ #elif defined (G_HAS_CONSTRUCTORS) #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(gobject_init_ctor) +#elif defined(__hpux) && defined(__ia64) +#pragma INIT "gobject_init_ctor" #endif G_DEFINE_CONSTRUCTOR(gobject_init_ctor) Index: gobject/gobject.c =================================================================== --- gobject/gobject.c.orig 2015-10-14 12:52:57.000000000 +0000 +++ gobject/gobject.c 2016-02-28 20:27:16.523167348 +0000 @@ -337,6 +337,8 @@ #ifdef G_HAS_CONSTRUCTORS #ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA #pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(debug_objects_atexit) +#elif defined(__hpux) && defined(__ia64) +#pragma FINI "debug_objects_atexit" #endif G_DEFINE_DESTRUCTOR(debug_objects_atexit) #endif /* G_HAS_CONSTRUCTORS */
_______________________________________________ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list