Reputation: 2499
I use C++ for project, there includes a c header file ira.h as below:
#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
When I compile it, I got error as below:
/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
What can I do?
Upvotes: 1
Views: 307
Reputation: 409432
GCC parses the characters sequence :::
as two operators: The scope operator ::
and a colon :
. It's because it matches the longest sequence it can when parsing keywords and operators. If you don't want that you need to add a space between each colon, like : : :
Upvotes: 7