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

Hiesgen, Raphael Raphael.Hiesgen at haw-hamburg.de
Fri Sep 26 16:00:39 CEST 2014


Hi,

first of all, thanks for the discussion and help!
Using the native port on Linux with gcc this seems to work:

> +    /* manually call other contructors in __init_array which haven't been called */
> +    typedef void (*func_ptr)(void);
> +    extern func_ptr __init_array_start[];
> +    extern func_ptr __init_array_end[];
> +    int size = __init_array_end - __init_array_start;
> +    int i, flag = 0;
> +    for (i = 0; i < size; i++) {
> +        if (__init_array_start[i] == startup) {
> +            flag = 1;
> +            continue;
> +        }
> +        if (flag == 1){
> +            (__init_array_start[i])();
> +        }
> +    }
>      kernel_init();
>  }

I will use this fix for now.

Thank you,
Raphael


More information about the devel mailing list