diff options
| author | Bernard Xiong <[email protected]> | 2014-11-01 14:12:58 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2014-11-01 14:12:58 +0800 |
| commit | 1974bec8bf09e2e4e26bfc67ae0664c1b032eaae (patch) | |
| tree | 8e82a9fbd9ac92f2fb355f9be2d3cda8826b56c3 /components/cplusplus/crt_init.c | |
| parent | 38be10cf89958872e15e650ba1271b234554d7e6 (diff) | |
[C++] fix the ctors initialization issue
Diffstat (limited to 'components/cplusplus/crt_init.c')
| -rw-r--r-- | components/cplusplus/crt_init.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c new file mode 100644 index 0000000000..20f81cdb54 --- /dev/null +++ b/components/cplusplus/crt_init.c @@ -0,0 +1,24 @@ +#include <rtthread.h> + +int cplusplus_system_init(void) +{ +#if defined(__GNUC__) && !defined(__CC_ARM) + extern unsigned char __ctors_start__; + extern unsigned char __ctors_end__; + typedef void (*func)(void); + + /* .ctors initalization */ + func *ctors_func; + + for (ctors_func = (func *)&__ctors_start__; + ctors_func < (func *)&__ctors_end__; + ctors_func ++) + { + (*ctors_func)(); + } +#endif + + return 0; +} +INIT_COMPONENT_EXPORT(cplusplus_system_init); + |
