当前位置: 技术问答>linux和unix
请问可以用宏定义定义一个二维数组吗?
来源: 互联网 发布时间:2015-12-27
本文导语: 如题: 一般#define都是定义一个字符串,数字或函数,请问它可以定义一个二维数组吗 | Of cource yes. But i think it is not good to decalare arrays with #define. when you use the folloing preprocessor, ...
如题:
一般#define都是定义一个字符串,数字或函数,请问它可以定义一个二维数组吗
一般#define都是定义一个字符串,数字或函数,请问它可以定义一个二维数组吗
|
Of cource yes. But i think it is not good to decalare arrays with #define. when you use the folloing preprocessor, you need to obey the C/C++ sytax rule for decalaring arrays.
#define TWO_DIM_CHAR_ARRAY(x,m,n) char x[m][n];
TWO_DIM_CHAR_ARRAY(what, 2,3) // this is the same with "char what[2][3];"
#define TWO_DIM_CHAR_ARRAY(x,m,n) char x[m][n];
TWO_DIM_CHAR_ARRAY(what, 2,3) // this is the same with "char what[2][3];"