Reputation: 1636
I print out the output of C preprocessor by using
gcc -E a.c
The output contains many lines like
# 1 "a.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "a.c"
# 1 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/stdio.h" 1 3
# 19 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/stdio.h" 3
# 1 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h" 1 3
# 31 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h" 3
# 32 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h" 3
# 20 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/stdio.h" 2 3
I've never seen this kind of syntax in C. Can someone explain what this is doing?
Upvotes: 71
Views: 42668
Reputation: 4295
These linemarkers are mentioned in man gcc
for -P
option.
The -P
option is specifically meant to get rid of these lines for clarity:
gcc -E -P source.c
See detailed documentation (answered before).
Upvotes: 50
Reputation: 61389
Those are line synchronization directives, which allow gcc
to give correct error messages for errors in #include
d files. Other preprocessors (such as yacc
/bison
) use the same mechanism to relate C errors to the correct lines in the input .y
file.
Upvotes: 2
Reputation: 19938
These lines are hints for debugging (where the code following the line actually came from)
# line-number "source-file" [flags]
Meaning of flags (space separated):
Upvotes: 82