我使用C++进行项目,其中包括ac头文件ira.h,如下所示:
#ifdef __cplusplus
extern "C" {
#endif
extern inline void disable_irqs() {
__asm__ __volatile__("\torc #0x80,ccr\n":::"cc");
}
extern inline void enable_irqs() {
__asm__ __volatile__("\tandc #0x7f,ccr\n":::"cc");
}
#ifdef __cplusplus
}
#endif
Run Code Online (Sandbox Code Playgroud)
当我编译它时,我得到如下错误:
/usr/local/bin/h8300-hitachi-hms-g++ -DCXX -fno-rtti -fno-exceptions -O2 -fno-builtin -fomit-frame-pointer -Wall -I/brickos/include -I/brickos/include/lnp -I. -I/brickos/boot -c rcx1.C -o rcx1.o
In file included from PowerFunctionsController.H:32,
from rcx1.H:27,
from rcx1.C:21:
/brickos/include/lnp/sys/irq.h: In function `void disable_irqs(...)':
/brickos/include/lnp/sys/irq.h:99: parse error before `::'
/brickos/include/lnp/sys/irq.h: In function `void enable_irqs(...)':
/brickos/include/lnp/sys/irq.h:104: parse error before `::'
make: *** [rcx1.o] Error 1
Run Code Online (Sandbox Code Playgroud)
我能做什么?
GCC将字符序列解析:::为两个运算符:范围运算符::和冒号:.这是因为它匹配解析关键字和运算符时可以使用的最长序列.如果你不想要,你需要在每个冒号之间添加一个空格,比如: : :