Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 594
Brendan Long Avatar asked Jun 01 '10 01:06

Brendan Long


People also ask

Does preprocessor remove all comments?

Removing comments : It removes all the comments. A comment is written only for the humans to understand the code. So, it is obvious that they are of no use to a machine. So, preprocessor removes all of them as they are not required in the execution and won't be executed as well.

What is the preprocessor statement in C?

The C preprocessor is a macro preprocessor (allows you to define macros) that transforms your program before it is compiled. These transformations can be the inclusion of header files, macro expansions, etc.

What is C preprocessor explain any two C preprocessor commands with example?

Preprocessors ExamplesUse #define for constants to increase readability. These directives tell the CPP to get stdio. h from System Libraries and add the text to the current source file. The next line tells CPP to get myheader.

What are preprocessor definitions?

In computer science, a preprocessor (or precompiler) is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers.


1 Answers

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

like image 112
WhirlWind Avatar answered Sep 21 '22 16:09

WhirlWind