简体   繁体   中英

What is <built-in> in C++ preprocessor output?

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, eg, __cplusplus , in case of command line, the macro is defined on the command-line, ie, -DMACRO=1 .

You can see a list of predefined macros:

cpp -dM foo.h  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM