![shequ.stmicroelectronics.cn](./template/st_v1/static/img/logo2.png)
程序内容如下 / CMSIS compiler specific defines / ifndef __ASMdefine ASM asmendif/ CMSIS compiler specific defines / 编译报错日志需要如何解决 ../Drivers/CMSIS/Include/cmsis_armcc.h:58:50: error: expected identifier or '(' before '__asm' 58 | #define ASM asm | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:211:57: note: in expansion of macro '__ASM' 211 | attribute((section(".rev16_text"))) STATIC_INLINE __ASM uint32_t REV16(uint32_t value) | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:58:50: error: expected identifier or '(' before '__asm' 58 | #define ASM asm | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:226:57: note: in expansion of macro '__ASM' 226 | attribute((section(".revsh_text"))) STATIC_INLINE __ASM int16_t REVSH(int16_t value) | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:58:50: error: expected identifier or '(' before '__asm' 58 | #define ASM asm | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:413:55: note: in expansion of macro '__ASM' 413 | attribute((section(".rrx_text"))) STATIC_INLINE __ASM uint32_t RRX(uint32_t value) | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__set_CONTROL': ../Drivers/CMSIS/Include/cmsis_armcc.h:178:43: warning: implicit declaration of function '__isb' [-Wimplicit-function-declaration] 178 | #define ISB() isb(0xF) | ^~~~~ |
stm32f407这个STM32_RCC_PERIPHCLK_SDMMC 是哪里定义的
简单聊聊STM32的SPI外设
STM32F405随机脉冲计数的定时器通道选择问题
STM32H7和F4做永磁同步电机FOC控制如何选型,哪个开发更好?
使用Cubeprogrammer无法连接、连接G431和一块H750的板子可以连上但是连另外一块H750的板子和F407的板子就直接报错,这个应该如何解决。
STM32F407的高速USB,采用的是虚拟串口方式,VCP驱动有linux系统的吗
如何使用TIM2的更新事件触发TIM1的PWM DMA
RAM 容量不足导致的数据溢出问题及优化方案
stm32f407的flash内容没有做任何事情,但是它的内容改变了。
给uint32_t数组填充整型值,除使用循环赋值外有没有c库函数可以实现
去年宏定义字符中间的空格,改成如下试试:
ifndef __ASM
define __ASM
......
endif
[md]谢谢 这样试了不行
../Drivers/CMSIS/Include/cmsis_armcc.h:57:2: error: invalid preprocessing directive #ifndef__ASM
57 | #ifndef__ASM
| ^
~~../Drivers/CMSIS/Include/cmsis_armcc.h:58:4: error: invalid preprocessing directive #define__ASM58 | #defineASM asm
| ^
~~../Drivers/CMSIS/Include/cmsis_armcc.h:211:57: error: unknown type name '__ASM'211 | attribute((section(".rev16_text"))) STATIC_INLINE __ASM uint32_t REV16(uint32_t value)
| ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:211:72: error: expected '=', ',', ';', 'asm' or 'attribute' before '__REV16'
211 | attribute((section(".rev16_text"))) STATIC_INLINE __ASM uint32_t REV16(uint32_t value)
| ^
~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:226:57: error: unknown type name '__ASM'226 | attribute((section(".revsh_text"))) STATIC_INLINE __ASM int16_t REVSH(int16_t value)
| ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:226:71: error: expected '=', ',', ';', 'asm' or 'attribute' before '__REVSH'
226 | attribute((section(".revsh_text"))) STATIC_INLINE __ASM int16_t REVSH(int16_t value)
| ^
~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:413:55: error: unknown type name '__ASM'413 | attribute((section(".rrx_text"))) STATIC_INLINE __ASM uint32_t RRX(uint32_t value)
| ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:413:70: error: expected '=', ',', ';', 'asm' or 'attribute' before '__RRX'
413 | attribute((section(".rrx_text"))) STATIC_INLINE __ASM uint32_t RRX(uint32_t value)
| ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__get_CONTROL':
../Drivers/CMSIS/Include/cmsis_armcc.h:560:42: error: expected '=', ',', ';', 'asm' or 'attribute' before '__ASM'
560 | register uint32_t regControl ASM("control");
| ^~~~~
宏定义命令与字符之间至少需要一个空格,字符内部不能有空格。
ifndef的判断字符要与后一句的字符相同,否则容易出现重定义的错误。
您的判断字符是"__ASM",而之后定义的却是 "ASM asm",这样前面的判断语句就失去了作用。
define ASM asm的意思是定义一个宏"ASM",其值为"asm"。您确定是要这样做吗?
建议复制下列代码:
[md]你好 代码如下 还是一样报错 谢谢 #ifndef __ASM #define __ASM __asm #endif
[md]改成这样会多出来其他的很多报错 谢谢 ../Drivers/CMSIS/Include/cmsis_armcc.h:212:3: error: unknown type name 'rev16' 212 | rev16 r0, r0 | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:213:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bx' 213 | bx lr | ^~ ../Drivers/CMSIS/Include/cmsis_armcc.h:225:71: error: invalid storage class for function '__REVSH' 225 | __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) | ^~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__REVSH': ../Drivers/CMSIS/Include/cmsis_armcc.h:227:3: error: unknown type name 'revsh' 227 | revsh r0, r0 | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:228:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bx' 228 | bx lr | ^~ ../Drivers/CMSIS/Include/cmsis_armcc.h:412:70: error: invalid storage class for function '__RRX' 412 | __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__RRX': ../Drivers/CMSIS/Include/cmsis_armcc.h:414:3: error: unknown type name 'rrx' 414 | rrx r0, r0 | ^~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:415:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bx' 415 | bx lr | ^~ ../Drivers/CMSIS/Include/cmsis_armcc.h:557:26: error: invalid storage class for function '__get_CONTROL' 557 | __STATIC_INLINE uint32_t __get_CONTROL(void) | ^~~~~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__get_CONTROL': ../Drivers/CMSIS/Include/cmsis_armcc.h:559:48: error: expected declaration specifiers or '...' before string constant 559 | register uint32_t __regControl __ASM("control"); | ^~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:560:10: error: '__regControl' undeclared (first use in this function) 560 | return(__regControl); | ^~~~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:560:10: note: each undeclared identifier is reported only once for each function it appears in ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__RRX': ../Drivers/CMSIS/Include/cmsis_armcc.h:569:22: error: invalid storage class for function '__set_CONTROL' 569 | __STATIC_INLINE void __set_CONTROL(uint32_t control) | ^~~~~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__set_CONTROL': ../Drivers/CMSIS/Include/cmsis_armcc.h:571:48: error: expected declaration specifiers or '...' before string constant 571 | register uint32_t __regControl __ASM("control"); | ^~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:572:3: error: '__regControl' undeclared (first use in this function) 572 | __regControl = control; | ^~~~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:177:43: warning: implicit declaration of function '__isb' [-Wimplicit-function-declaration] 177 | #define __ISB() __isb(0xF) | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:573:3: note: in expansion of macro '__ISB' 573 | __ISB(); | ^~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__RRX': ../Drivers/CMSIS/Include/cmsis_armcc.h:582:26: error: invalid storage class for function '__get_IPSR' 582 | __STATIC_INLINE uint32_t __get_IPSR(void) | ^~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__get_IPSR': ../Drivers/CMSIS/Include/cmsis_armcc.h:584:46: error: expected declaration specifiers or '...' before string constant 584 | register uint32_t __regIPSR __ASM("ipsr"); | ^~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:585:10: error: '__regIPSR' undeclared (first use in this function); did you mean '__get_IPSR'? 585 | return(__regIPSR); | ^~~~~~~~~ | __get_IPSR ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__RRX': ../Drivers/CMSIS/Include/cmsis_armcc.h:594:26: error: invalid storage class for function '__get_APSR' 594 | __STATIC_INLINE uint32_t __get_APSR(void) | ^~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__get_APSR': ../Drivers/CMSIS/Include/cmsis_armcc.h:596:46: error: expected declaration specifiers or '...' before string constant 596 | register uint32_t __regAPSR __ASM("apsr"); | ^~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:597:10: error: '__regAPSR' undeclared (first use in this function); did you mean '__get_APSR'? 597 | return(__regAPSR); | ^~~~~~~~~ | __get_APSR ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__RRX': ../Drivers/CMSIS/Include/cmsis_armcc.h:606:26: error: invalid storage class for function '__get_xPSR' 606 | __STATIC_INLINE uint32_t __get_xPSR(void) | ^~~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__get_xPSR': ../Drivers/CMSIS/Include/cmsis_armcc.h:608:46: error: expected declaration specifiers or '...' before string constant 608 | register uint32_t __regXPSR __ASM("xpsr"); | ^~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h:609:10: error: '__regXPSR' undeclared (first use in this function) 609 | return(__regXPSR); | ^~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__RRX': ../Drivers/CMSIS/Include/cmsis_armcc.h:618:26: error: invalid storage class for function '__get_PSP' 618 | __STATIC_INLINE uint32_t __get_PSP(void) | ^~~~~~~~~ ../Drivers/CMSIS/Include/cmsis_armcc.h: In function '__get_PSP': ../Drivers/CMSIS/Include/cmsis_armcc.h:620:53: error: expected declaration specifiers or '...' before string constant 620 | register uint32_t __regProcessStackPointer __ASM("psp"); | ^~~~~
这些报错与宏定义关系不大,需要针对相应出错的代码进行检查,尤其是需要在IDE平台检查相应的文件路径是否包含了。宏定义是没有再报错了。
[md]这么改不太对 换成iar没这个报错