Jump to content

  • Log In with Google      Sign In   
  • Create Account


Help with export


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 noatom   Members   -  Reputation: 781

Like
0Likes
Like

Posted 14 December 2012 - 11:17 AM

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; }; // classtypedef 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.

Sponsor:

#2 Khatharr   Crossbones+   -  Reputation: 2913

Like
0Likes
Like

Posted 14 December 2012 - 11:30 AM

Putting the function pointer typedef within the scope of the extern "C" effects the mangling behavior.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#3 noatom   Members   -  Reputation: 781

Like
0Likes
Like

Posted 14 December 2012 - 12:07 PM

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?!

Edited by noatom, 14 December 2012 - 12:58 PM.


#4 Shannon Barber   Moderators   -  Reputation: 1361

Like
0Likes
Like

Posted 18 December 2012 - 08:51 PM

It affects everything in the C++ namespace. extern "C" drops you into the C namespace.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS