[riot-devel] RIOT and static initializers in C++

Pekka Nikander pekka.nikander at iki.fi
Mon Sep 22 19:56:04 CEST 2014

>>>>  __attribute__((constructor)) static void startup(int argc, char **argv)

This is probably a stupid question, but why in the first place are you declaring startup as a constructor? As there are no guarantees (without priorities) in which order the constructors are called, that is somewhat unsafe.

If you want to take care of all initialisations yourself, IMHO you should declare startup as the entry point in the linker command line (or script), i.e. for both GNU ld and for Mac OS X linker

  ld -e startup  

But then, of course, you have to take care of explicitly initialising anything else that your native runtimes require, that differs slightly between Linux, FreeBSD and OSX, and requires some work.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4827 bytes
Desc: not available
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20140922/39faa742/attachment.bin>

More information about the devel mailing list