阅读:729回复:3
提个C的问题(有分)
请问怎么在#DEFINE 里面使用#if 和#endif啊?
就是象下面的一个定义 #define ENTRY(ClassType,proc1,proc2) \\ void ClassType::Entry(ClassType *p) \\ { \\ #if(proc1 != NULL) \\ proc1(); #endif \\ #if(proc2 != NULL) \\ proc2(); #endif \\ } 这个proc1和proc2有可能是0,NULL,或者类成员函数就是想要实现一个编译的时候由编译器判断的 如果proc1是NULL的话,那么就不调用proc1了! 如果proc2是NULL的话,那么就不调用proc2了! |
|
沙发#
发布于:2003-06-16 11:55
为什么这样不对
#define AAA 1 #define A(a) (#if AAA==1 1 #else 1 #endif) 而这样却是可以的 #define AAA 1 #define A (#if AAA==1 1 #else 1 #endif) |
|
板凳#
发布于:2003-06-16 12:11
为什么不这样?
#define ENTRY(ClassType,proc1,proc2) \\ void ClassType::Entry(ClassType *p) \\ { \\ if(proc1 != NULL) \\ proc1(); \\ if(proc2 != NULL) \\ proc2(); \\ } |
|
地板#
发布于:2003-06-16 12:35
就是有问题啊!编译的时候出错了啊!
为什么下面这样不对 #define AAA 1 #define A(a) (#if AAA==1 1 #else 1 #endif) 而下面这样却是可以的 #define AAA 1 #define A() (#if AAA==1 1 #else 1 #endif) |
|