0

These are the first few lines of the pre-processor output of a simple C program. What do they mean?

# 1 "test.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 325 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.c" 2
# 1 "some_path/stdio.h" 1 3 4
# 64 "some_path/stdio.h" 3 4

Here's my program:

#include <stdio.h>

int main()
{
    printf("Hello, World!\n");
    return 0;
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ram
  • 1,161
  • 1
  • 11
  • 34
  • Have you read the manual for your compiler? For example [gcc preprocessor output](https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html). If so, please explain what specifically you don't understand after reading the manual. – kaylum Jan 14 '16 at 05:56

1 Answers1

0
 # linenum filename flags

These are called linemarkers. They are inserted as needed into the output (but never within a string or character constant). They mean that the following line originated in file filename at line linenum. filename will never contain any non-printing characters; they are replaced with octal escape sequences.

After the file name comes zero or more flags, which are ‘1’, ‘2’, ‘3’, or ‘4’. If there are multiple flags, spaces separate them. Here is what the flags mean:

  • ‘1’ This indicates the start of a new file.
  • ‘2’ This indicates returning to a file (after having included another file).
  • ‘3’ This indicates that the following text comes from a system header file, so certain warnings should be suppressed.
  • ‘4’ This indicates that the following text should be treated as being wrapped in an implicit extern "C" block.

Source: GCC Manual

5gon12eder
  • 24,280
  • 5
  • 45
  • 92
Sunil Bojanapally
  • 12,528
  • 4
  • 33
  • 46