Summary: C++ preprocessor output includes some lines that say <built-in>
. I'm curious to know what these are for.
Details:
When I compile the following code in a file named test.cpp
with clang++ -E
(output from g++
is similar):
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
the first few lines of output are as follows:
# 1 "test.cpp"
# 1 "test.cpp" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 156 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.cpp" 2
My question is what do the <built-in>
statements mean.
A macro expands to "1", and in case of built-in, the macro is defined by default, e.g., __cplusplus
, in case of command line, the macro is defined on the command-line, i.e., -DMACRO=1
.
You can see a list of predefined macros:
cpp -dM foo.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With