Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4255446
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: C/C++

2011-05-26 17:22:59

ANSI C中包含哪些标准宏定义呢??

__LINE__               记录当前宏所在源文件的行号
__FILE__               记录当前源文件的名称
__DATE__               记录当前日期
__TIME__               记录当前时间
__STDC__               判断是否进行 ANSI C编译,如果为1 将定义该宏,否则                       不定义
__cplusplus            判断是C++还是C,如果使用的是C编译器,该宏不被定义

注意:
     __STDC__ 和 __cplusplus 只允许在宏定义中使用,不允许用来输出

#define
#undef



  1. #include <stdio.h>

  2. int main()
  3. {
  4.     printf("the file is %s.\n",__FILE__);
  5.     printf("the data is %s.\n",__DATE__);
  6.     printf("the time is %s.\n",__TIME__);
  7.     printf("this is line %d\n",__LINE__);

  8.     return 0;
  9. }

  1. ywx@yuweixian:~/yu/c$ ./defi
  2. the file is defi.c.
  3. the data is May 26 2011.
  4. the time is 17:21:16.
  5. this is line 9

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