Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 506
Gabriel Southern Avatar asked Feb 21 '13 22:02

Gabriel Southern


1 Answers

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  
like image 166
perreal Avatar answered Oct 23 '22 05:10

perreal