简体   繁体   English

什么是 <built-in> 在C ++预处理器输出?

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

Summary : C++ preprocessor output includes some lines that say <built-in> . 简介 :C ++预处理器输出包含一些说明<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): 当我在一个名为test.cpp的文件中使用clang++ -E编译以下代码时( g++输出类似):

#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 "test.cpp" 1 #1“test.cpp”1
# 1 "<built-in>" 1 #1“<内置>”1
# 1 "<built-in>" 3 #1“<内置>”3
# 156 "<built-in>" 3 #156“<内置>”3
# 1 "<command line>" 1 #1“<命令行>”1
# 1 "<built-in>" 2 #1“<内置>”2
# 1 "test.cpp" 2 #1“test.cpp”2

My question is what do the <built-in> statements mean. 我的问题是<built-in>语句是什么意思。

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 . 宏扩展为“1”,并且在内置的情况下,宏默认定义,例如__cplusplus ,在命令行的情况下,宏在命令行上定义,即-DMACRO=1

You can see a list of predefined macros: 您可以看到预定义宏的列表:

cpp -dM foo.h  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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