【发布时间】:2014-08-14 12:44:00
【问题描述】:
我正在尝试为共享库的延迟加载创建一个代理类。
该库的API函数之一是:
int AttachCWnd(CWnd* pControl);
所以,我创建了一个宏来轻松地声明和路由从代理类到库的调用:
class CLibProxy {
public:
typedef int (*tAttachCWnd)(CWnd*);
tAttachCWnd m_fAttachCWnd;
};
#define DECL_ROUTE(name, ret, args) \
ret CLibProxy::name args \
{ \
if (m_hDLL) \
return m_f##name (args); \
return ret(); \
}
DECL_ROUTE(AttachCWnd, int, (CWnd* pControl));
但是在 VS2010 上编译失败:
error C2275: 'CWnd' : illegal use of this type as an expression
谁能解释一下原因?
【问题讨论】:
-
查看preprocessed source应该会很明显。
标签: c++ windows dll macros loadlibrary