解决keil5.38编译stm32报四个错误问题
Start/core_cm3.c(445): error: non-ASM statement in naked function is not supported uint32_t result=0; ^ Start/core_cm3.c(442): note: attribute is here uint32_t __get_PSP(void) __attribute__( ( naked ) ); ^ Start/core_cm3.c(465): error: parameter references not allowed in naked functions "BX lr " : : "r" (topOfProcStack) ); ^ Start/core_cm3.c(461): note: attribute is here void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) ); ^ Start/core_cm3.c(479): error: non-ASM statement in naked function is not supported uint32_t result=0; ^ Start/core_cm3.c(476): note: attribute is here uint32_t __get_MSP(void) __attribute__( ( naked ) ); ^ Start/core_cm3.c(499): error: parameter references not allowed in naked functions "BX lr " : : "r" (topOfMainStack) ); ^ Start/core_cm3.c(495): note: attribute is here void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) ); ^ 4 errors generated. compiling core_cm3.c... compiling system_stm32f10x.c... compiling stm32f10x_tim.c... ".Objectsstm32.axf" - 4 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:02
解决方法:是因为keil5.38使用了6的编译器,网上大多数都是切换到5编译器,我的办法是将core_cm3.h、core_cm3.c文件替换成新的core_cm3.h文件,将core_cm3.c删除。同时在当前目录下添加一下文件。
以下为报错前的start目录
替换后的start目录为:
替换以后可以看到,编译已经成功了
我将以上四个文件打包到百度网盘,需要的自取:
链接: https://pan.baidu.com/s/1LwcrzeGtvcWIPvyJHwscCw?pwd=6666 提取码: 6666 复制这段内容后打开百度网盘手机App,操作更方便哦
