So I have a header file like this:
[source lang="cpp"]class ZFXRenderDevice {
protected:
HWND m_hWndMain; // application main window
HWND m_hWnd[MAX_3DHWND]; // 3D render window handle
UINT m_nNumhWnd; // number of hwnds in array
UINT m_nActivehWnd; // which one is active (0=main hWnd)
HINSTANCE m_hDLL; // dll module handle
DWORD m_dwWidth; // screen width
DWORD m_dwHeight; // screen height
bool m_bWindowed; // windowed mode?
char m_chAdapter[256]; // graphics adapter name
bool m_bRunning; // after succesful initialization
FILE *m_pLog; // log file
public:
ZFXRenderDevice(void) {};
virtual ~ZFXRenderDevice(void) {};
// INIT/RELEASE STUFF:
// ===================
// initialize engine, should first display dialog to select
// graphics adapter and mode, and then start the 3D API
virtual HRESULT Init(HWND, const HWND*, int, int, int, bool)=0;
virtual HRESULT InitWindowed(HWND, const HWND*, int, bool)=0;
// release API specific stuff
virtual void Release(void)=0;
// is initialized?
virtual bool IsRunning(void)=0;
// RENDERING STUFF:
// ================
// switch swap chain to hwnd in array from Init()
virtual HRESULT UseWindow(UINT nHwnd)=0;
// clear buffers and prepare for rendering
virtual HRESULT BeginRendering(bool bClearPixel,
bool bClearDepth,
bool bClearStencil)=0;
// end rendering and flip pixel buffer to front
virtual void EndRendering(void)=0;
// clear pixel-, depth-, stencil-buffer
virtual HRESULT Clear(bool, bool, bool)=0;
// change background color
virtual void SetClearColor(float fRed, float fGreen, float fBlue)=0;
}; // class
typedef class ZFXRenderDevice *LPZFXRENDERDEVICE;
/*----------------------------------------------------------------*/
extern "C" {
HRESULT CreateRenderDevice(HINSTANCE hDLL, ZFXRenderDevice **pInterface);
HRESULT ReleaseRenderDevice(ZFXRenderDevice **pInterface);
typedef HRESULT (*RELEASERENDERDEVICE)(ZFXRenderDevice **pInterface);
}
/*----------------------------------------------------------------*/
[/source]
So when an instance of that class gets created,the variables in it get created too right? But what about that extern "C"? From what I googled I found that those functions are decleared here,but will be implemented somewhere else.
And the typedef? I mean the typedef creates a pointer type called RELEASERENDERDEVICE.
What I don't understand is why put that typedef under extern? Why not just put it above the class?! I mean it's just a definition,it doesn't actually create a RELEASERENDERDEVICE pointer.
Help with export
Putting the function pointer typedef within the scope of the extern "C" effects the mangling behavior.
so the c++ mangling problem affects even function pointers? I thought only functions...
Are you sure that the name mangling problem affects function pointers too?!
Are you sure that the name mangling problem affects function pointers too?!
It affects everything in the C++ namespace. extern "C" drops you into the C namespace.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement