On Wed, 16 Dec 2009, Przemysław Czerpak wrote:

hi,

 > The problem is trivial. GCC-2.96 when C++ mode is used ignores
 > __attribute__ ((constructor)) and does not add functions with
 > above attribute to .ctors segment. Looks like it was fixed in
 > one of GCC-3.3x releases but I do not know the exact version.

i think 3.3.6 was the last of the 3.3s, but anyway.

i have a hunch that i am verifying now (only 3.3 g++ is done so far, 
this is a slow machine, but so far the only result i have is 
promising): change the order of initializers.

this makes g++ fall into the static category (because of __cplusplus), 
not into using fun attributes (because of __GNUC__); moreover this 
makes all c++ compilers fall into this, which i gather is preferred, 
if one is capable of doing c++-style initializers.

this has so far fixed g++-3.3, but i'm still running tests and 
re-tests and re-tests.

Index: include/hbinit.h
===================================================================
--- include/hbinit.h    (revision 13266)
+++ include/hbinit.h    (working copy)
@@ -112,6 +112,33 @@
    #define HB_CALL_ON_STARTUP_END( func ) \
       }
 
+#elif defined( HB_STATIC_STARTUP ) || defined( __cplusplus )
+
+   #if defined( HB_PRAGMA_STARTUP ) || defined( HB_DATASEG_STARTUP )
+      #error Wrong macros set for startup code - clean your make/env settings.
+   #endif
+
+   #define HB_INIT_SYMBOLS_BEGIN( func ) \
+      static HB_SYMB symbols_table[] = {
+
+   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
+      }; \
+      static PHB_SYMB symbols = hb_vmProcessSymbols( symbols_table, (USHORT) ( 
sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
+
+   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
+      static int func( void ) \
+      {
+
+   /* this allows any macros to be preprocessed first
+      so that token pasting is handled correctly */
+   #define HB_CALL_ON_STARTUP_END( func ) \
+          _HB_CALL_ON_STARTUP_END( func )
+
+   #define _HB_CALL_ON_STARTUP_END( func ) \
+         return 0; \
+      } \
+      static int static_int_##func = func();
+
 #elif defined( HB_INITSEG_STARTUP )
 
    #if defined( HB_PRAGMA_STARTUP ) || defined( HB_DATASEG_STARTUP )
@@ -216,33 +243,6 @@
     *  See the C output of a generated prg for example
     */
 
-#elif defined( HB_STATIC_STARTUP ) || defined( __cplusplus )
-
-   #if defined( HB_PRAGMA_STARTUP ) || defined( HB_DATASEG_STARTUP )
-      #error Wrong macros set for startup code - clean your make/env settings.
-   #endif
-
-   #define HB_INIT_SYMBOLS_BEGIN( func ) \
-      static HB_SYMB symbols_table[] = {
-
-   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
-      }; \
-      static PHB_SYMB symbols = hb_vmProcessSymbols( symbols_table, (USHORT) ( 
sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
-
-   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
-      static int func( void ) \
-      {
-
-   /* this allows any macros to be preprocessed first
-      so that token pasting is handled correctly */
-   #define HB_CALL_ON_STARTUP_END( func ) \
-          _HB_CALL_ON_STARTUP_END( func )
-
-   #define _HB_CALL_ON_STARTUP_END( func ) \
-         return 0; \
-      } \
-      static int static_int_##func = func();
-
 #elif defined( HB_PRAGMA_STARTUP ) || \
       defined( __BORLANDC__ ) || defined( __LCC__ ) || defined( __POCC__ ) || 
defined( __XCC__ )
 

 > It will be good to check exact version to enable in hbinit.h
 > HB_STATIC_STARTUP initialization for older GCC versions using
 > C++ mode. Or maybe we should enable it by default for _ALL_
 > (also MSVC) compilers using C++ mode? Unlike all other startup
 > initialization methods this one uses only standard C++ functionality
 > without any compiler specific tricks so it's fully portable code
 > in C++ world.

i think i am in favor of this.


-- 
[-]

mkdir /nonexistent
Index: include/hbinit.h
===================================================================
--- include/hbinit.h	(revision 13266)
+++ include/hbinit.h	(working copy)
@@ -112,6 +112,33 @@
    #define HB_CALL_ON_STARTUP_END( func ) \
       }
 
+#elif defined( HB_STATIC_STARTUP ) || defined( __cplusplus )
+
+   #if defined( HB_PRAGMA_STARTUP ) || defined( HB_DATASEG_STARTUP )
+      #error Wrong macros set for startup code - clean your make/env settings.
+   #endif
+
+   #define HB_INIT_SYMBOLS_BEGIN( func ) \
+      static HB_SYMB symbols_table[] = {
+
+   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
+      }; \
+      static PHB_SYMB symbols = hb_vmProcessSymbols( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
+
+   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
+      static int func( void ) \
+      {
+
+   /* this allows any macros to be preprocessed first
+      so that token pasting is handled correctly */
+   #define HB_CALL_ON_STARTUP_END( func ) \
+          _HB_CALL_ON_STARTUP_END( func )
+
+   #define _HB_CALL_ON_STARTUP_END( func ) \
+         return 0; \
+      } \
+      static int static_int_##func = func();
+
 #elif defined( HB_INITSEG_STARTUP )
 
    #if defined( HB_PRAGMA_STARTUP ) || defined( HB_DATASEG_STARTUP )
@@ -216,33 +243,6 @@
     *  See the C output of a generated prg for example
     */
 
-#elif defined( HB_STATIC_STARTUP ) || defined( __cplusplus )
-
-   #if defined( HB_PRAGMA_STARTUP ) || defined( HB_DATASEG_STARTUP )
-      #error Wrong macros set for startup code - clean your make/env settings.
-   #endif
-
-   #define HB_INIT_SYMBOLS_BEGIN( func ) \
-      static HB_SYMB symbols_table[] = {
-
-   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
-      }; \
-      static PHB_SYMB symbols = hb_vmProcessSymbols( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
-
-   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
-      static int func( void ) \
-      {
-
-   /* this allows any macros to be preprocessed first
-      so that token pasting is handled correctly */
-   #define HB_CALL_ON_STARTUP_END( func ) \
-          _HB_CALL_ON_STARTUP_END( func )
-
-   #define _HB_CALL_ON_STARTUP_END( func ) \
-         return 0; \
-      } \
-      static int static_int_##func = func();
-
 #elif defined( HB_PRAGMA_STARTUP ) || \
       defined( __BORLANDC__ ) || defined( __LCC__ ) || defined( __POCC__ ) || defined( __XCC__ )
 
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to