This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

cmsis_gcc.h compilation error if "nrf.h" is included from c++ file.

Hello 

I know that C++ is not officially supported but I wonder whether somebody else had the same problem.  I can compile an example project with gcc (mingw32-make) and compilation is successful if I just add a c++ file to the list of source file in the make file. However I get compilation errors in cmsis_gcc.h as soon as I add any nordic related header file to the c++ file. 

The include is wrapped in extern "C" {}. SDK is nRF5_SDK_17.0.0_9d13099

Would be nice to be able use C++ with arm gcc toolchain. 

Here the error messages:

../../../nRF5SDK17009d13099/nRF5_SDK_17.0.0_9d13099/components/toolchain/cmsis/include/cmsis_gcc.h: In function 'void __cmsis_start()':
../../../nRF5SDK17009d13099/nRF5_SDK_17.0.0_9d13099/components/toolchain/cmsis/include/cmsis_gcc.h:146:31: error: type 'const __cmsis_start()::__copy_table_t' with no linkage used to declare variable 'const __cmsis_start()::__copy_table_t __copy_table_start__' with linkage [-Werror]
extern const __copy_table_t __copy_table_start__;
^
../../../nRF5SDK17009d13099/nRF5_SDK_17.0.0_9d13099/components/toolchain/cmsis/include/cmsis_gcc.h:147:31: error: type 'const __cmsis_start()::__copy_table_t' with no linkage used to declare variable 'const __cmsis_start()::__copy_table_t __copy_table_end__' with linkage [-Werror]
extern const __copy_table_t __copy_table_end__;
^
../../../nRF5SDK17009d13099/nRF5_SDK_17.0.0_9d13099/components/toolchain/cmsis/include/cmsis_gcc.h:148:31: error: type 'const __cmsis_start()::__zero_table_t' with no linkage used to declare variable 'const __cmsis_start()::__zero_table_t __zero_table_start__' with linkage [-Werror]
extern const __zero_table_t __zero_table_start__;
^
../../../nRF5SDK17009d13099/nRF5_SDK_17.0.0_9d13099/components/toolchain/cmsis/include/cmsis_gcc.h:149:31: error: type 'const __cmsis_start()::__zero_table_t' with no linkage used to declare variable 'const __cmsis_start()::__zero_table_t __zero_table_end__' with linkage [-Werror]
extern const __zero_table_t __zero_table_end__;
^
cc1plus.exe: all warnings being treated as errors
mingw32-make: *** [../../../nRF5SDK17009d13099/nRF5_SDK_17.0.0_9d13099/components/toolchain/gcc/Makefile.common:276: _build/nrf52840_xxaa/test.cpp.o] Error 1

I'll appreciate any hints or comments. 

Best Regards,
Anton

Related