changes for C++ constructors on psim
JP Bonn
rtemsmail at jpbonn.eioMAIL.com
Fri May 7 03:12:42 UTC 2004
..snip...
>>>+
>>>+ void my_ctor (void) __attribute__ ((constructor));
>>>+ void
>>>+ my_ctor (void)
>>>+ {
>>>+ printf ("hello before main()\n");
>>>+ }
>>>
>> As Chris already mentioned, C constructors are a GCC extension.
>> Therefore this function should be guarded by __GNUC__ #defines.
>>
>> Also, you are adding "my_ctor" to a C++ file, i.e. you actually are
>> attributing a C++ function as constructor. If you want to test C
>> constructors, this function should be put into a separate *.c file, or
>> be marked 'extern "C"'.
>>
>> Another issue is the '__attribute__(..)'.
>> This is a GCC internal define. If you want the code to be portable you
>> have to define it for non-GCC compilers.
>
>Why was this even needed? I thought there were already global
>constructors in this test?
No, it's not needed - I figured if we were testing constructors it
wouldn't hurt to try the GCC attribute also. (Assuming it's ifdef for GCC.)
-------------------------------
The best kept secret in e-mail.
http://eioMAIL.com
More information about the users
mailing list