字符串常量之前的预期声明说明符或“...”

Posted

技术标签:

【中文标题】字符串常量之前的预期声明说明符或“...”【英文标题】:Expected declaration specifiers or '...' before string constant 【发布时间】:2012-01-02 12:39:42 【问题描述】:

下面代码第二行的scplugin project 中的mach_override.c 出现Expected declaration specifiers or '...' before string constant 错误。

asm(        
            ".text;"
            ".align 2, 0x90;"
            ".globl _atomic_mov64;"
            "_atomic_mov64:;"
            "   pushl %ebp;"
            "   movl %esp, %ebp;"
            "   pushl %esi;"
            "   pushl %ebx;"
            "   pushl %ecx;"
            "   pushl %eax;"
            "   pushl %edx;"

            // atomic push of value to an address
            // we use cmpxchg8b, which compares content of an address with 
            // edx:eax. If they are equal, it atomically puts 64bit value 
            // ecx:ebx in address. 
            // We thus put contents of address in edx:eax to force ecx:ebx
            // in address
            "   mov     8(%ebp), %esi;"  // esi contains target address
            "   mov     12(%ebp), %ebx;"
            "   mov     16(%ebp), %ecx;" // ecx:ebx now contains value to put in target address
            "   mov     (%esi), %eax;"
            "   mov     4(%esi), %edx;"  // edx:eax now contains value currently contained in target address
            "   lock; cmpxchg8b (%esi);" // atomic move.

            // restore registers
            "   popl %edx;"
            "   popl %eax;"
            "   popl %ecx;"
            "   popl %ebx;"
            "   popl %esi;"
            "   popl %ebp;"
            "   ret"
);

Allow asm, inline typeof 标志在我的构建设置中设置。谁能帮帮我?

【问题讨论】:

【参考方案1】:

进行以下更改(在标志中):

C language dialect = Compiler Default 

【讨论】:

以上是关于字符串常量之前的预期声明说明符或“...”的主要内容,如果未能解决你的问题,请参考以下文章

“&”标记之前的预期声明说明符或“...”

错误:数字常量之前的预期';',','或')[关闭]

Java编程中如何区分常量和变量?

常变量和变量,常量的区别与联系,各自的特点是啥

常量和常变量有啥区别没

[C/C++]_[初级]_[声明和使用字符串常量和字节常量]