1

I am exporting functions from a static library as follows:

extern "C"
{
    __declspec(dllexport) HRESULT CreateGraphicsDevice(HINSTANCE hDLL,  IAMG3DGraphicsDevice **pInterface);
}

All my code is written in C++, so I don't see why I need to extern "C". For example, if I put:

extern __declspec(dllexport) HRESULT CreateGraphicsDevice(HINSTANCE hDLL,  IAMG3DGraphicsDevice ** pInterface)

the function is not accessible from the DLL. Why is extern "C" required if my code is written in c++ as opposed to putting extern directly before the function declaration?

c0der
  • 95
  • 1
  • 1
  • 4
  • you can and export without `extern "C"` - in this case you name will be decorated in `c++` style. and you not need `extern` keyword before `__declspec(dllexport)`. however `the function is not accessible from the DLL` - what you mean under this ? – RbMm Jan 03 '17 at 13:21

0 Answers0