如何删除C预处理器默认添加到输出顶部的行?

时间:2010-06-01 01:58:23

标签: c-preprocessor

我正在尝试在非C代码上使用 C 预处理器,除了在顶部创建这样的行之外它工作正常:

# 1 "test.java"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.java"

问题是这些行在Java中无效。有没有办法让预处理器不写这些东西?我宁愿不必通过别的方式来运行它,只是每次都删除前4行。

1 个答案:

答案 0 :(得分:25)

如果您正在使用gcc预处理器:

   -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.

来自gcc cpp手册页