Chinaunix首页 | 论坛 | 博客
  • 博客访问: 112612
  • 博文数量: 17
  • 博客积分: 1430
  • 博客等级: 上尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-13 12:10
文章分类
文章存档

2010年(1)

2009年(5)

2008年(11)

我的朋友

分类: C/C++

2008-10-16 15:19:16


1,

#include

using namespace std;

#define DEBUG(x) cout << "DEBUG(x): " #x " = " << x << endl

#define VAR_DEFINE(name) int name##_int

#define VAR(name)   name##_int

int main()
{

   int x = 1;

   DEBUG(x);  //DEBUG(x): x = 1

   VAR_DEFINE(one);
   VAR(one) = 10;
   DEBUG(VAR(one));   // DEBUG(x): VAR(one) = 10


  return 0;
}

2,

//#define PRINT(msg, args...) printf(msg, ##args)   vc无法编译通过 gcc可以
//#define PRINT(msg, ...) printf(msg, __VA_ARGS__)  vc编译通过 gcc不可以
#define PRINT(msg, ...) printf(msg, ##__VA_ARGS__)
阅读(1103) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~