Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ekiwi
Copy link

@ekiwi ekiwi commented Jan 11, 2016

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 roboterclubaachen/xpcc#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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants