我现在愿意编译我的项目,-std=c99和我面对我不是一时理解错误。这一行:

my_type* td = ({ register kmy_type* arg0 asm("eax"); arg0; });

给我以下错误仅在C99:

warning: ISO C forbids nested functions
error: syntax error before ‘asm’
error: ‘arg0’ undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
warning: ISO C forbids braced-groups within expressions

任何线索,欢迎来帮助我理解这意味着什么。我不写这行,我也没有一定要明白什么是它的目的。

有帮助吗?

解决方案

my_type* td = ({ register my_type* arg0 asm("eax"); arg0; });

应该得到在eax寄存器中的值,解释为指针,进td变量。但是,它使用许多GNU的扩展,特别声明表情和这种使用asm的(明确的寄存器分配)的。我建议您切换到-std = gnu99(或任何它被称为)。否则,你可能希望使用双下划线(如asm - > __asm)打球。或者__extension__关键字,但我不知道这是否会在C99模式帮助

编辑:我刚刚试了一下,简单地改变asm__asm作品

其他提示

asm()似乎不使用-std=c99工作。这在我看来是一个坏主意,因为标准实际上表明,编译器支持asm()关键字,但它不是强制性的。

我建议你使用-pedantic代替。

在问题没有ASM,看起来像它为arg0

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top