宏定义学习笔记之一:初入江湖

源文件代码如下:

1 #include "stdafx.h"
2 using namespace std;
3 #include <iostream>
4 #define  T 1
5 #define ABC void main() \
6     {cout<<"hello!"<<<<endl;}
7 #include "abc.h"
8 

头文件代码如下:abc.h

1 #if T
2 char s[] = "good morning!";
3  ABC
4 #endif

替换后代码如下:

1 #include "stdafx.h"
2 using namespace std;
3 #include <iostream>
4 char s[] = "good morning!";
5 void main()
6  {
7     cout<<"hello!"<<<<endl;
8  }

执行后哦输出如下:

hello! good morning!

做个快乐的自己。
原文地址:https://www.cnblogs.com/Jessy/p/1772667.html