Note that there are some explanatory texts on larger screens.

plurals
  1. PORun-time error caused by wrong calling convention
    primarykey
    data
    text
    <p>I have the following class definition:</p> <pre><code>class IRenderable { public: virtual void Render( wxBitmap * ) = 0; } class MyClass : public wxWindow, public IRenderable { public: /* costructor, destructor etc... */ void RenderBitmap( wxBitmap *bitmap ) { // code } } </code></pre> <p>where wxWindow and wxBitmap are classes belonging to wxWidgets library (a C++ portable library for writing GUI applications).</p> <p>I am using Visual C. The following piece of code is wrong:</p> <pre><code>MyClass *c = new MyClass(...); wxWindow *w = (wxWindow *)c; IRenderable *r_page = (IRenderable *)w; // bitmap is allocate somewhere else r_page-&gt;RenderBitmap( bitmap ); </code></pre> <p>because i get a runtime error:</p> <blockquote> <p>Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.</p> </blockquote> <p>What's going on? </p> <p>What i am doing is the following. A third-party library (wxAUI) get pointers to wxWindow in order to manage them. I have sublcassed wxWindow (MyClass) to add some specific code. So, instead of managing wxWindows objects i am using MyClass objects. In some situations, i ask wxAUI to return me the wxWindow pointer of the "current" window, which should be a pointer to MyClass object. I want to call the RenderBitmap() method on those objects, so i need to cast it to IRenderable, but get that run-time error...</p> <p>I do not have RTTI enable and don't now if this would solve the problem...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload