CMSIS_4
CMSIS_4 copied to clipboard
include/cmsis_gcc.h: only read define if it exists
I am getting some compiler warnings from gcc when using CMSIS headers in a
Cortex-M0 project, e.g.
xpcc/ext/cmsis/stm32/Include/core_cmInstr.h:541:36: warning: "__CORTEX_SC" is not defined [-Wundef]
#if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
See also https://github.com/roboterclubaachen/xpcc/issues/52.
This patch should fix this issue for users of cortex-m as well as ARM SecureCore cores. It has the following underlying assumptions:
- If CMSIS is used on a cortex-m core,
__CORTEX_Mwill be defined to be the correct core version, while__CORTEX_SCwill be undefined. - If CMSIS is used on a ARM SecureCore core,
__CORTEX_SCwill be defined to be the correct core version, while__CORTEX_Mwill be undefined. - Thus, only one of the two defines will exists at a time.
In order to avoid compiler warnings, this patch adds checks for the existence of the defines before accessing them.