C中的ASM给出-std = c99的错误

cla*_*laf 4 c assembly c99 inline-assembly

我现在愿意编写我的项目,-std=c99并且我正面临一个我目前不理解的错误.这一行:

my_type* td = ({ register kmy_type* arg0 asm("eax"); arg0; });
Run Code Online (Sandbox Code Playgroud)

仅在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
Run Code Online (Sandbox Code Playgroud)

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

jpa*_*cek 12

这条线

my_type* td = ({ register my_type* arg0 asm("eax"); arg0; });
Run Code Online (Sandbox Code Playgroud)

应该将eax寄存器中的值(解释为指针)变为td变量.但是,它使用了大量的GNU扩展,特别是语句表达式和asm(显式寄存器分配)的使用.我建议你切换到-std = gnu99(或者不管它叫什么).否则,你可能想要使用双下划线(例如asm- > __asm)或__extension__关键字,但我不知道它是否有助于c99模式.

编辑:我只是尝试了它,只是asm改为__asm工作.