Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1760298
  • 博文数量: 335
  • 博客积分: 4690
  • 博客等级: 上校
  • 技术积分: 4341
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-08 21:38
个人简介

无聊之人--除了技术,还是技术,你懂得

文章分类

全部博文(335)

文章存档

2016年(29)

2015年(18)

2014年(7)

2013年(86)

2012年(90)

2011年(105)

分类: 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~~~~~~~~~~~~~~~~~~~~~


阅读(1684) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~