How to remove lines added by default by the C preprocessor to the top of the output?
Asked Answered
W

1

31

I'm trying to use the C preprocessor on non-C code, and it works fine except for creating lines like this at the top:

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

The problem is that these lines aren't valid in Java. Is there any way to get the preprocessor to not write this stuff? I'd prefer not to have to run this through something else to just remove the first 4 lines every time.

Webber answered 1/6, 2010 at 1:58 Comment(3)
That's the filthiest use of C preprocessor I have ever seen... I wish I thought of it when I was doing Java coding.Twandatwang
I figured there's no reason C coders should have all the fun when it comes to unreadable code..Webber
What those lines mean: #5371039Dewittdewlap
Y
45

If you're using the gcc preprocessor:

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

from gcc cpp man page

Yonne answered 1/6, 2010 at 2:2 Comment(1)
Works with mingw too!Palinode

© 2022 - 2024 — McMap. All rights reserved.