#define 封装可变参数的函数

[ 2010-03-24 16:36:50 | 作者: Admin ]
字体大小: | |
#define WRITE_CONSOLE_LOG(type, format, ...) \
WriteLog(type, format, __VA_ARGS__ ); \

不要忘记了。
评论Feed 评论Feed: http://www.azure.com.cn/feed.asp?q=comment&id=426

浏览模式: 显示全部 | 评论: 1 | 引用: 0 | 排序 | 浏览: 1318
ziyan0618
[ 2010-04-07 16:46:59 ]
[cry]
怎么用啊,
// 宏定义可变长函数.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "stdlib.h"
#define MAX(...) maxx3((A),(B),(C))

int maxx(int a,int b)
{
  return a>b?a:b;
}

int maxx3(int a,int b,int c)
{

  int aa=maxx(b,c);

  return a>aa?a:aa;
}

int _tmain(int argc, _TCHAR* argv[])
{

  printf("%d\n",MAX(55,66,88));

  system("PAUSE");
  return 0;
}

1>正在编译...
1>stdafx.cpp
1>正在编译...
1>宏定义可变长函数.cpp
1>.\宏定义可变长函数.cpp(33) : error C2065: “A”: 未声明的标识符
1>.\宏定义可变长函数.cpp(33) : error C2065: “B”: 未声明的标识符
1>.\宏定义可变长函数.cpp(33) : error C2065: “C”: 未声明的标识符
1>生成日志保存在“file://d:\Backup\我的文档\Visual Studio 2005\Projects\Test1\宏定义可变长函数\Release\BuildLog.htm”
1>宏定义可变长函数 - 3 个错误,0 个警告
========== 全部重新生成: 0 已成功, 1 已失败, 0 已跳过 ==========

此日志不可发表评论.
ħ˽ ħ˽