代码之家  ›  专栏  ›  技术社区  ›  Brendan Long

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

  •  16
  • Brendan Long  · 技术社区  · 14 年前

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

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

    问题是,这些行在Java中无效。有没有办法让预处理器不写这些东西?我不希望每次都要通过其他方法来删除前4行。

    1 回复  |  直到 9 年前
        1
  •  25
  •   WhirlWind    14 年前

    如果使用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手册页