C/C++程序编译过程
以hello.c
为例
1 #include <stdio.h>
2
3 int main()
4 {
5 #ifdef __cplusplus
6 printf("cplusplus\n");
7 #endif
8 printf("hello world\n");
9
10 return 0;
11 }
当使用gcc
编译(C
编译器)时,输出:

当使用g++
编译(C++
编译器)时,输出:

g++编译器定义了_cplusplus
这个宏,而gcc没有。
以上编译过程,都可以分解为如下动作: