无聊之人--除了技术,还是技术,你懂得
分类: C/C++
2013-02-03 23:32:01
最近在看python源码分析的时候发现,很多C语言的基础知识都已经忘的差不多,因此自己在动手熟悉一把,
#include需要说明的是宏的一些细节问题,#include #include #define DEBUG_H #ifdef DEBUG_H #define xman_info (printf("my name is%s\nage is %d\naddress is %s\n",man.name,man.age,man.address)) #else #define xman_info printf("XMAN NOTHING INFO\n") #endif /*******************/ #if 1 #define xmanp_info (printf("my name is%s\nage is %d\naddress is %s\n",m->name,m->age,m->address)) #else #define xmanp_info printf("XMAN NOTHING INFO\n") #endif /******************/ typedef struct { char * name; int age; char * address; }xman; int main(int argc,char * argv[]){ xman * m; xman man = {"kinfinger ",22,"pudong"}; /* struct init*/ m = &man; xman_info; xmanp_info; }
#ifdef DEBUG_H
#if 1
一个是根据宏是否定义来进行条件编译,
一个是根据宏常量表达式来进行判断,该宏常量表达式也可以用宏来进行定义
syntax:
# if constant-expression new-line groupopt
# ifdef identifier new-line groupopt
over~~~~~~~~~~~~~~~~~~~~~