Chinaunix首页 | 论坛 | 博客
  • 博客访问: 51230
  • 博文数量: 16
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 195
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-05 14:28
文章分类

全部博文(16)

文章存档

2013年(16)

我的朋友

分类: C/C++

2013-10-05 18:32:15

1、#define

#define MAX(a,b) ((a) > (b)?(a) : (b))
...
x=5;
y=8;
z=MAX(x++,y++);
printf("x=%d,y=%d,z=%d\n",x,y,z);

打印结果:x=6,y=10,z=9;

2、#undef

该条预处理器指令用于移除一个宏定义

3#if条件编译

3.1语法形式:
#if constant-expression
    statements
#endif

3.2是否被定义
#if    defined[symble]
#ifdef symble
#if    !defined[symble]
#ifndef symble

例如:
#if    defined(OS_UNIX)
    #ifdef OPTION1
        unix_version_of_option1();
    #endif
    #ifdef OPTION2
        unix_version_of_option2();
    #endif
#elif defined(OS_MSDOS)
    #ifdef OPTION2
        msdos_version_of_option2();
    #endif
#endif
4、#error
语法格式:#error text of error message







阅读(1568) | 评论(0) | 转发(2) |
0

上一篇:关于字符串

下一篇:关于I/O

给主人留下些什么吧!~~