What is this C++ language construct: # (i.e. hash) integer "path_to_header_or_cpp_file" <integer>?

c++, gcc, header-files, syntax

Solution

This is output from the GCC preprocessor. Those lines are known as linemarkers. They have the syntax:

# linenum filename flags

They are interpreted as saying that the following line has come from the line `linenum` from `filename`. They basically just help you and the compiler see where lines were included from. The flags provide some more information:

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

You can see this output from preprocessing your own programs if you give the `-E` flag to g++.

Problem

I came across the following code in a .cpp file. I do not understand the construct or syntax which involves the header files. I do recognize that these particular header files relate to Android NDK. But, I think the question is a general question about C++ syntax. These appear to be preprocessor commands in some way because they begin with "#". But, they are not the typical #include, #pragma, #ifndef, #define, etc. commands. The source file has more 1000+ such occurrences referencing hundreds of different .h, .c, .cpp files. ``` typedef int __time_t; typedef int __timer_t; # 116 "/home/usr/download/android-ndk-r8b/platforms/android-3/arch-arm/usr/include/machine/_types.h" # 41 "/home/usr/download/android-ndk-r8b/platforms/android-3/arch-arm/usr/include/sys/_types.h" 2 # 33 "/home/usr/download/android-ndk-r8b/platforms/android-3/arch-arm/usr/include/stdint.h" 2 # 48 "/home/usr/download/android-ndk-r8b/platforms/android-3/arch-arm/usr/include/stdint.h" typedef __int8_t int8_t; typedef __uint8_t uint8_t; ``` The compiler (GCC) does not appear to be throwing any error related to these lines. But, I would like to understand their purpose and function. Can anybody explain these?

Original source