2012-09-19 71 views
5

我只想得到预处理版本file.cc。我做了g++ -E file.cc,得到:g ++预处理器输出

# 1 "file.cc" 
# 1 "<command-line>" 
# 1 "file.cc" 

我做错了什么?

+1

提高您的文章。源文件中有什么等 –

+4

源文件必须为空? – trojanfoe

+1

除非你说出你做了什么,以及你期望发生什么,否则我们无法知道你做错了什么。 – tenfour

回答

10

假设你的源文件中包含一个简单的主要功能:

$ cat file.cc 
int main() { 
    return 0; 
} 

然后,你表现的命令,输出看起来是这样的:

$ g++ -E file.cc 
# 1 "file.cc" 
# 1 "<built-in>" 
# 1 "<command-line>" 
# 1 "file.cc" 

int main() { 
    return 0; 
} 

这是在显示输出问题发生在file.cc为空时。请注意,“空”表示该文件仍可以包含注释或#ifdef块,其条件的计算结果为false - 由于预处理器将其过滤掉,所以它们也不会出现在输出中。

4

如果你不想让行标志,使用-P选项:

-P 
    Inhibit generation of linemarkers in the output from the preprocessor. This might 
    be useful when running the preprocessor on something that is not C code, and will 
    be sent to a program which might be confused by the linemarkers.