首先define 定义的宏只会在本文件中做替换。
但是我们会遇到这么一个问题
比如我们定义一个宏,但是我不知道我定义的这个宏是在本文件还是在本文件include进来的头文件。
如#define **
#define ***
#define ****
#define test 100
上面这几个宏分散定义在include 头文件和本文件中。
现在我要定义一个宏为#define test 200但是我不知道这个宏之前是否已经定义了。我就可以使用如下的语句
#if defined test
#undef test
#define test 200
#endif
上面的语句意思是说如果你之前定义了宏。那么就取消这个宏定义,重新定义这个宏