2

For a simple C program I did gcc -E hello.c -o hello.pp to see how the program looks after preprocessing.

In the output file I can see many lines which start with #, that look like comment. What are these lines?

How can I see only the C code, without those comments?

Below is a snippet:

user $ gcc -E hello.c -o hello.pp
user $ tail -n 15 hello.pp

extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;

extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
# 943 "/usr/include/stdio.h" 3 4

# 3 "hello.c" 2
int main() 
{
     printf("Hello world \n");

     return 0;
}
user $ 
jww
  • 97,681
  • 90
  • 411
  • 885
sps
  • 2,720
  • 2
  • 19
  • 38
  • Voting to reopen because of the original question of *"How can I see only the C code, without those comments?"* – jww Feb 28 '17 at 02:35

1 Answers1

7

"How can I see only the C code, without those comments ?"

You can use gcc with options -E -P to get rid of the # lines of the preprocessor output.

From gcc documentation:

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

ouah
  • 142,963
  • 15
  • 272
  • 331