I am currently using predefined cpu target macros to make software run on multiple cpu targets.
#ifdef __TARGET_CPU_CORTEX_M0
[do something here]
#elif __TARGET_CPU_CORTEX_M3
[do something here]
#else
#error Unsupported compiler platform
#endif
Example:
This works for Cortex-M0 and Cortex-M3, but I can't figure out what macro to use for Cortex-M0+. Does anyone know which macro I can use? I use the armcc compiler.
This is documented , albeit rather obliquely. The relevant macro name is derived from the command-line option, thus --cpu=Cortex-M0plus
defines __TARGET_CPU_CORTEX_M0PLUS
.
Annoyingly, whilst it doesn't show up in the --cpu=list
output, the compiler (I tried armcc version 5.04) does also recognise the option --cpu=Cortex-M0+
, for which it defines the macro __TARGET_CPU_CORTEX_M0_
In general, invoking armcc --cpu=xx --list_macros /dev/null
will show what macros are defined for cpu option xx (or an error if it isn't supported).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.