A persistant problem that people using the C++ compiler from the "GNU Tools for ARM Embedded Processors" toolchain has been the way that G++ handles the inline-assembly for the SVC
instruction.
Specifically, you get an impossible constraint in 'asm'
error when trying to use any softdevice header.
There have been a few questions about this here on the Nordic Developer Zone, here for example, with putative answers on StackOverflow.
However, myself and others have found that the "insert a cast" answer on StackOverflow does not work with the latest (4.9) G++ under the -Os
optimization mode. Digging into the issue, it appears that different code generation and optimization options make it hit-and-miss with being able to use the GNU G++ compiler.
Note that often GCC will work even though G++ does not because the rules of type-inference for enum
differ substantially between C and C++. For the current GNU compilers, even explicitly setting the type via enum : unsigned char { ... }
does not work (and might be a compiler bug).
Therefore, I've created a tool on GitHub that automagically translates Nordic's enum
header files into Keil-compatible #define
constants.
Since I can't release the modified Nordic SDKs, I've opted to release the tool, enum2define.py and just the patch files under the MIT license.
Comments and suggestions (and better yet, patches) are gratefully accepted.