Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » if malloc and remalloc are on a boat...

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
if malloc and remalloc are on a boat...
Thomas Fjellstrom
Member #476
June 2000
avatar

hmmm...

void my_function(); //whatever this does

class __call_before_main { 
public:__call_before_main ( void (*func)()) {func();}
};
#define CALL_BEFORE_MAIN(a) static __call_before_main __call_ ## a ( a ) ;
CALL_BEFORE_MAIN(my_function);

is not equivelent to:

void __attribute__((constructor)) my_function() { }

thats 'GCC C' but Im sure thiers methods for other compilers, that I don't use... ;)

And with some nice defines like yours above it can be just as compiler independent. (unless of course your compiler uses a #pragma directive to set a constructor)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bob
Free Market Evangelist
September 2000
avatar

You can use _Pragma in that case :)

#define FOO(bar) _Pragma blah(bar)

--
- Bob
[ -- All my signature links are 404 -- ]

 1   2   3 


Go to: