[riot-devel] RIOT and static initializers in C++
pekka.nikander at iki.fi
Sat Sep 27 14:35:41 CEST 2014
If you want to stay close to Posix, IMHO you should retain main, perhaps even with (compile-time constant) argc and argv there, too. And perhaps also allow main to return (only to be called again, perhaps), or call exit, to reboot the device.
If Posix-compliance is not a strict goal, it doesn't really matter what you want to call the entry point to the application. You have to document anyway, carefully, what happens before the application entry point is called, as there is no single right way in the embedded world.
On 2014–09–27, at 15:30 , Ludwig Ortmann <ludwig.ortmann at fu-berlin.de> wrote:
> Does anyone know if this approach would only benefit native, or other toolchains as well?
> Cheers, Ludwig
> Am 26. September 2014 23:56:36 MESZ, schrieb Ryan Kurte <ryankurte at gmail.com>:
>> I was just reading and wondering, would it be easier just to drop main
>> the application name?
>> So long as it is well documented it shouldn't make a huge difference to
>> And that way the toolchain should take care of all the initialization
>> needs to.
>> On Sep 23, 2014 6:24 AM, "Ludwig Ortmann" <ludwig.ortmann at fu-berlin.de>
>>> Hi pekka,
>>> On 22. September 2014 19:56:04 MESZ, Pekka Nikander
>> <pekka.nikander at iki.fi>
>>>>>>>> __attribute__((constructor)) static void startup(int argc,
>>>> This is probably a stupid question, but why in the first place are
>>>> declaring startup as a constructor? As there are no guarantees
>>>> priorities) in which order the constructors are called, that is
>>>> somewhat unsafe.
>>> Because it worked when I first tried it, because I did not know too
>>> about the initialization process, and:
>>>> But then, of course, you have to take care of explicitly
>>>> anything else that your native runtimes require, that differs
>>>> between Linux, FreeBSD and OSX, and requires some work.
>>> .. this, after I dug a bit deeper ;)
>>> And finally, because this assumption does not hold:
>>>> If you want to take care of all initialisations yourself,
>>> Really, all this is just to allow "main" as the user application
>> name, so
>>> I didn't want to add unnecessary complexity.
>>> Cheers, Ludwig
>>> devel mailing list
>>> devel at riot-os.org
>> devel mailing list
>> devel at riot-os.org
> devel mailing list
> devel at riot-os.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4827 bytes
Desc: not available
More information about the devel