C++ 对函数声明使用宏展开时出错

C++ 对函数声明使用宏展开时出错,c++,windows,dll,macros,loadlibrary,C++,Windows,Dll,Macros,Loadlibrary,我正在尝试为延迟加载共享库创建一个代理类 库的API函数之一是: int AttachCWnd(CWnd* pControl); 因此,我创建了一个宏来轻松声明和路由从代理类到库的调用: class CLibProxy { public: typedef int (*tAttachCWnd)(CWnd*); tAttachCWnd m_fAttachCWnd; }; #define DECL_ROUTE(name, ret, args) \ ret CLibProxy::nam

我正在尝试为延迟加载共享库创建一个代理类

库的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

有人能解释为什么吗?

嗯,显然是个错误。调用m_fattachwnd不应包含类型声明,而应仅包含参数:

return m_fAttachCWnd (CWnd* pControl);
应该成为

return m_fAttachCWnd (pControl);
谢谢@chris。

查看,它应该变得显而易见。