C Preprocessor adds comments of its own
- If any, what are the (obviously ignored by GCC) comments below called?
- How do I get rid of them?
Here:
eisbaw@len开发者_Python百科o:~/GCC$ cpp < /dev/null
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
eisbaw@leno:~/GCC$
They are called linemarkers and you can use -P
to have cpp
or gcc
omit them.
They are described in the Preprocessor Output section of the cpp
manual.
And I agree with user30997 that you probably don't want to get rid of them. They are ignored by gcc
in the sense that they do not affect the compilation process, but they do provide useful diagnostic information when your code does not compile correctly.
You probably don't want to get rid of them. They are inserted by the precprocessor so that any compiler that reads this compilation unit can determine the source file and line number that spawned any line it examines. Without it, you can't get meaningful errors like "syntax error on line 7 of main.cpp: semicolon expected." Or whatever.
If you REALLY want to ditch them, you can always just write something quick that will kill anything beginning with "# ".
精彩评论