gcc的手册页说明
file.s
Assembler code.
file.S
file.sx
Assembler code that must be preprocessed.
Run Code Online (Sandbox Code Playgroud)
许多标准包含文件都有
#ifndef __ASSEMBLY__
...
#endif
Run Code Online (Sandbox Code Playgroud)
包装器允许从程序集文件中包含.我可以发誓我以前用gcc写过程序,并在组装时定义了这个程序,但现在我遇到了问题.
这是一些测试代码:
test.S
#include <sys/syscall.h>
#include <asm/signal.h>
.intel_syntax noprefix
.text
.global foo // int foo(int pid)
foo:
mov esi,SIGUSR1
mov eax,SYS_kill
syscall
ret
Run Code Online (Sandbox Code Playgroud)
当我运行时gcc -c test.S,它抱怨asm/signal.h中的所有类型的东西,因为它没有看到__ASSEMBLY__定义.
现在我的工作是:
#ifndef __ASSEMBLY__
#define __ASSEMBLY__
#endif
Run Code Online (Sandbox Code Playgroud)
但这似乎是错误的,必须将其添加到我的所有文件.
这是GCC中的错误吗?
或者我在这里做错了什么?
注意:
我在测试中看到gcc确实定义__ASSEMBLER__但是大多数头文件测试__ASSEMBLY__(我确实看到了一对测试__ASSEMBLER__).适当的ifdef在某些时候发生了变化吗?
我使用的是Ubuntu 14.04,gcc报告版本:gcc(Ubuntu 4.8.2-19ubuntu1)4.8.2