2 回答

TA贡献1951条经验 获得超3个赞
参考一下:
就是把命名空间声明与宏定义组合起来用
namespace nsdebug //名字空间nsdebug是在别的文件里定义的
{
int GetStringWidth(char* s);
int GetCellValue(int x,int y);
}
#define GetStringWidth nsdebug::GetStringWidth
#define GetCellValue nsdebug::GetCellValue
把这些个名字空间都加近来,再一一定义一个宏,做成一个新的头文件。这样的话不必修改原来代码的任何内容。

TA贡献1900条经验 获得超5个赞
我也曾遇到过这中问题,曾经也找到了解决方案,但是觉得不完美后来就不用了,不过可以给你参考一下:
就是把命名空间声明与宏定义组合起来用
namespace nsdebug //名字空间nsdebug是在别的文件里定义的
{
int GetStringWidth(char* s);
int GetCellValue(int x,int y);
}
#define GetStringWidth nsdebug::GetStringWidth
#define GetCellValue nsdebug::GetCellValue
把这些个名字空间都加近来,再一一定义一个宏,做成一个新的头文件。这样的话不必修改原来代码的任何内容。
不过后来我觉得用宏还是不稳心,东西多了次早会遇到宏陷阱,后来就废弃了这种方法。
- 2 回答
- 0 关注
- 808 浏览
添加回答
举报