命名空间和全局函数的使用一例
2011-12-08 14:02
585 查看
今天download工程的release version生成遇到一个问题,其实上一次在debug版本的时候也遇到了,只是没有仔细记录。
现象是: 引用dll里的ide::reporter()函数时,找不到该函数位置
------------------------------ide_programer.cpp----------------------
#ifdef DOWNLOAD_TOOL
ProcessReport &ide::reporter()
{
static ProcessReport report(APP_GUI);
return report;
}
#endif
------------------------------ide_msgglobal.h------------------------
#define GETMSG(...) ide::reporter().getMessage(__VA_ARGS__)
#define GETMSG_QSTR(...) QString::fromLocal8Bit((const char*)ide::reporter().getMessage(__VA_ARGS__))
#define QSTR_TO_LOCALE(x) (x).toLocal8Bit().constData()
#define QSTR_TO_CSTR(x) (x).toStdString().c_str()
namespace ide
{
extern ProcessReport &reporter();
}
最后查的原因是第一处的DOWNLOAD_TOOL宏定义未生效的缘故。
全局变量的定义和使用方式要注意,特别是使用了namespace之后。
现象是: 引用dll里的ide::reporter()函数时,找不到该函数位置
------------------------------ide_programer.cpp----------------------
#ifdef DOWNLOAD_TOOL
ProcessReport &ide::reporter()
{
static ProcessReport report(APP_GUI);
return report;
}
#endif
------------------------------ide_msgglobal.h------------------------
#define GETMSG(...) ide::reporter().getMessage(__VA_ARGS__)
#define GETMSG_QSTR(...) QString::fromLocal8Bit((const char*)ide::reporter().getMessage(__VA_ARGS__))
#define QSTR_TO_LOCALE(x) (x).toLocal8Bit().constData()
#define QSTR_TO_CSTR(x) (x).toStdString().c_str()
namespace ide
{
extern ProcessReport &reporter();
}
最后查的原因是第一处的DOWNLOAD_TOOL宏定义未生效的缘故。
全局变量的定义和使用方式要注意,特别是使用了namespace之后。
相关文章推荐
- 使用命名空间:后备全局函数/常量 ¶
- 使用命名空间和类中原本有的函数同时出现时的调用次序
- ASP.NET AJAX 说明文档->客户端引用->全局命名空间->JavaScript 基础类型扩展->Array 类型扩展->add 函数
- php命名空间与自动加载函数一起使用
- 函数定义命名空间的使用
- ASP.NET AJAX 说明文档->客户端引用->全局命名空间->JavaScript 基础类型扩展->Array 类型扩展->addRange 函数
- thinkphp3.2开发排错一例——没有使用命名空间导致没有自动加载类进而导致Class not found
- ASP.NET AJAX 说明文档->客户端引用->全局命名空间->JavaScript 基础类型扩展->Array 类型扩展->clear 函数
- :: 指出使用的函数在命名空间中
- PHP基础之命名空间8——后备全局函数/常量
- ASP.NET AJAX 说明文档->客户端引用->全局命名空间->JavaScript 基础类型扩展->Array 类型扩展->clone 函数
- ASP.NET AJAX 说明文档->客户端引用->全局命名空间->JavaScript 基础类型扩展->Array 类型扩展->contains 函数
- 命名空间及自动加载函数的使用
- python函数和方法都可以访问全局命名空间~这很有用但也很可怕
- C++在命名空间中使用函数模板
- C++中遇到同名函数问题,可以使用命名空间解决
- 5.1 Python 函数-默认参数,*args,**kwargs的使用;作用域-局部空间使用全局变量需要注意的事项等
- X3全局变量及公共函数所在的命名空间说明
- 命名空间的使用方法
- 头文件中不要使用命名空间 C++