CMSIS_4 icon indicating copy to clipboard operation
CMSIS_4 copied to clipboard

include/cmsis_gcc.h: only read define if it exists

Open ekiwi opened this issue 10 years ago • 0 comments

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_M will be defined to be the correct core version, while __CORTEX_SC will be undefined.
  • If CMSIS is used on a ARM SecureCore core, __CORTEX_SC will be defined to be the correct core version, while __CORTEX_M will 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.

ekiwi avatar Jan 11 '16 20:01 ekiwi