c_cpp 宏定义

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 宏定义相关的知识,希望对你有一定的参考价值。

#define EXIT_SUCCESS 0

#define SQUARE(x) x * x
but be careful. Because what happens if we attempt SQUARE(z-y)?
If this were a function, we would evaluate z-y to a value and copy it into 
the stack frame for a call to SQUARE, however, this is a macro expansion, 
so the preprocessor works only with text. It expands the macro by replacing x in
the macro definition with the text z-y, resulting in z-y * z-y. Note that this 
will compute z- (y*z) -y, which is not z-y squared.
Improvement:
#define SQUARE(x) ((x) * (x))

以上是关于c_cpp 宏定义的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp C ++ Windows和Linux导出库宏定义

c_cpp 宏回购

c_cpp iOS通用全球宏

c_cpp 使用宏来连接堆对象

c_cpp c中句柄的示例宏

c_cpp C ++ Setter Getter宏