0

I'm trying to create a proxy class for delayed load of a shared library.

One of the API function of the library is:

int AttachCWnd(CWnd* pControl);

So, I created a macro to easily declare and route calls from the proxy class to the library:

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));

But compilation fails on VS2010:

error C2275: 'CWnd' : illegal use of this type as an expression

Can anyone explain why?

Vality
  • 6,577
  • 3
  • 27
  • 48
liorda
  • 1,552
  • 2
  • 15
  • 38
  • 3
    View the [preprocessed source](http://coliru.stacked-crooked.com/a/7695258f1111bdcc) and it should become obvious. – chris Aug 14 '14 at 12:45

1 Answers1

0

Well, obvious mistake. Calling m_fAttachCWnd should not include the type declaration, but only the arguments:

return m_fAttachCWnd (CWnd* pControl);

should become

return m_fAttachCWnd (pControl);

Thanks @chris.

liorda
  • 1,552
  • 2
  • 15
  • 38