c - 编译内置 asm 时出错
问题描述
我最近从 Keil Uvision 切换到我自己的 Makefile 我在编译文件 port.c 时遇到问题,文件中的函数:
__asm void vPortSVCHandler( void )
{
PRESERVE8
/* Get the location of the current TCB. */
ldr r3, =pxCurrentTCB
ldr r1, [r3]
ldr r0, [r1]
/* Pop the core registers. */
ldmia r0!, {r4-r11, r14}
msr psp, r0
isb
mov r0, #0
msr basepri, r0
bx r14
}
编译时出现以下错误:
../port.c:52:7: error: expected '(' before 'void'
52 | __asm void vPortSVCHandler( void )
| ^~~~
| (
../port.c:64:13: error: stray '#' in program
64 | mov r0, #0
我是否缺少包含或编译器选项?
解决方案
您使用gcc
和 gcc 没有“asm”功能。
您需要在汇编程序中编写它或编写内联汇编。__asm
也不是有效的gcc
关键字。
推荐阅读
- amazon-web-services - 如何在 AWS Lambda 中创建身份验证中间件
- c++ - c++,在子类中,没有对象如何访问父类的方法?
- php - 用同名初始化php类
- javascript - FormArray 的 Angular .removeAt(i) 不会在 DOM 中更新 - Angular
- ios - Xcode 问题类型“XYZController”不符合协议
- python - 有没有办法用(1/2)的函数替换(输入)零?
- html - 如何在移相器中自动播放视频?
- sql - 使用 4 个表的 SQL MAX 查询
- c# - 使用 Ghostscript 快速栅格化部分 PDF
- c# - 使用 Where 的 SelectMany 查询会产生许多 SQL 查询