<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[invalid static cast]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche gerade ein Programm zu kompilieren, dass ich zwar nicht selbst geschreiben habe, aber ein wenig umändern wollte. Nun sagt er mir aber Folgendes:</p>
<pre><code class="language-cli">maggy:CancerSim praktikant$ make -f makefile2.txt
g++  -c -O3  `/Users/praktikant/Desktop/wxMac-2.8.10/build-ansi/wx-config --cxxflags`  -c -o wxGLCanvas2.o wxGLCanvas2.cc
wxGLCanvas2.cc:25: error: invalid static_cast from type ‘void (wxGLCanvas2::*)()’ to type ‘void (wxEvtHandler::*)(wxEraseEvent&amp;)’
make: *** [wxGLCanvas2.o] Error 1
</code></pre>
<p>Da ich ziemlich neu mit c++ bin, bin ich leider überfragt mit dieser Fehlermeldung. Bisherige Lösungen aus dem Internet haben bei mir leider nicht funktioniert, aber ich hab auch noch nicht so viele durch...</p>
<p>Hier auf jeden Fall mal die Codes:<br />
<a href="http://wxGLCanvas2.cc" rel="nofollow">wxGLCanvas2.cc</a></p>
<pre><code class="language-cpp">#include &quot;wxGLCanvas2.h&quot;

BEGIN_EVENT_TABLE(wxGLCanvas2, wxGLCanvas)
  EVT_PAINT(wxGLCanvas2::OnPaint)
  EVT_ERASE_BACKGROUND(wxGLCanvas2::OnEraseBackground)  //&lt;-- hier ist Zeile 25
END_EVENT_TABLE()

wxGLCanvas2::wxGLCanvas2(wxWindow * parent, wxGLCanvas2_Render * render)
  : wxGLCanvas(parent,-1), m_render(render)
{

}

void wxGLCanvas2::OnPaint(wxPaintEvent &amp; e)
{
  wxPaintDC dc(this);
//  cout &lt;&lt; &quot;wxGLCanvas2::OnPaint&quot; &lt;&lt; endl;
  SetCurrent();
  m_render-&gt;render();
  SwapBuffers();
}
</code></pre>
<p>wxGLCanvas2.h</p>
<pre><code class="language-cpp">#include &quot;wx/wx.h&quot;
#include &quot;wx/glcanvas.h&quot;

class wxGLCanvas2_Render
{
public:
  virtual void render() = 0;
};

class wxGLCanvas2 : public wxGLCanvas
{
  DECLARE_EVENT_TABLE()

public:

  wxGLCanvas2(wxWindow * parent, wxGLCanvas2_Render*);

  void OnEraseBackground() { };
  void OnPaint(wxPaintEvent&amp;);

protected:
  wxGLCanvas2_Render * m_render;
};
</code></pre>
<p>und der Teil von event.h, wo wxEvtHandler drin ist (event.h wird über wx/wx.h includiert)</p>
<pre><code class="language-cpp">// ----------------------------------------------------------------------------
// wxEvtHandler: the base class for all objects handling wxWidgets events
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
{
public:
    wxEvtHandler();
    virtual ~wxEvtHandler();

    wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
    wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
    void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
    void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }

    void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
    bool GetEvtHandlerEnabled() const { return m_enabled; }

    // process an event right now
    virtual bool ProcessEvent(wxEvent&amp; event);

    // add an event to be processed later
    void AddPendingEvent(wxEvent&amp; event);

    void ProcessPendingEvents();

#if wxUSE_THREADS
    bool ProcessThreadEvent(wxEvent&amp; event);
#endif

    // Dynamic association of a member function handler with the event handler,
    // winid and event type
    void Connect(int winid,
                 int lastId,
                 int eventType,
                 wxObjectEventFunction func,
                 wxObject *userData = (wxObject *) NULL,
                 wxEvtHandler *eventSink = (wxEvtHandler *) NULL);

    // Convenience function: take just one id
    void Connect(int winid,
                 int eventType,
                 wxObjectEventFunction func,
                 wxObject *userData = (wxObject *) NULL,
                 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }

    // Even more convenient: without id (same as using id of wxID_ANY)
    void Connect(int eventType,
                 wxObjectEventFunction func,
                 wxObject *userData = (wxObject *) NULL,
                 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); }

    bool Disconnect(int winid,
                    int lastId,
                    wxEventType eventType,
                    wxObjectEventFunction func = NULL,
                    wxObject *userData = (wxObject *) NULL,
                    wxEvtHandler *eventSink = (wxEvtHandler *) NULL);

    bool Disconnect(int winid = wxID_ANY,
                    wxEventType eventType = wxEVT_NULL,
                    wxObjectEventFunction func = NULL,
                    wxObject *userData = (wxObject *) NULL,
                    wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }

    bool Disconnect(wxEventType eventType,
                    wxObjectEventFunction func,
                    wxObject *userData = (wxObject *) NULL,
                    wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); }

    wxList* GetDynamicEventTable() const { return m_dynamicEvents ; }

    // User data can be associated with each wxEvtHandler
    void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
    wxClientData *GetClientObject() const { return DoGetClientObject(); }

    void SetClientData( void *data ) { DoSetClientData(data); }
    void *GetClientData() const { return DoGetClientData(); }

    // check if the given event table entry matches this event and call the
    // handler if it does
    //
    // return true if the event was processed, false otherwise (no match or the
    // handler decided to skip the event)
    static bool ProcessEventIfMatches(const wxEventTableEntryBase&amp; tableEntry,
                                      wxEvtHandler *handler,
                                      wxEvent&amp; event);

    // implementation from now on
    virtual bool SearchEventTable(wxEventTable&amp; table, wxEvent&amp; event);
    bool SearchDynamicEventTable( wxEvent&amp; event );

#if wxUSE_THREADS
    void ClearEventLocker();
#endif // wxUSE_THREADS

    // Avoid problems at exit by cleaning up static hash table gracefully
    void ClearEventHashTable() { GetEventHashTable().Clear(); }

private:
    static const wxEventTableEntry sm_eventTableEntries[];

protected:
    // hooks for wxWindow used by ProcessEvent()
    // -----------------------------------------

    // This one is called before trying our own event table to allow plugging
    // in the validators.
    //
    // NB: This method is intentionally *not* inside wxUSE_VALIDATORS!
    //     It is part of wxBase which doesn't use validators and the code
    //     is compiled out when building wxBase w/o GUI classes, which affects
    //     binary compatibility and wxBase library can't be used by GUI
    //     ports.
    virtual bool TryValidator(wxEvent&amp; WXUNUSED(event)) { return false; }

    // this one is called after failing to find the event handle in our own
    // table to give a chance to the other windows to process it
    //
    // base class implementation passes the event to wxTheApp
    virtual bool TryParent(wxEvent&amp; event);

    static const wxEventTable sm_eventTable;
    virtual const wxEventTable *GetEventTable() const;

    static wxEventHashTable   sm_eventHashTable;
    virtual wxEventHashTable&amp; GetEventHashTable() const;

    wxEvtHandler*       m_nextHandler;
    wxEvtHandler*       m_previousHandler;
    wxList*             m_dynamicEvents;
    wxList*             m_pendingEvents;

#if wxUSE_THREADS
#if defined (__VISAGECPP__)
    const wxCriticalSection&amp; Lock() const { return m_eventsLocker; }
    wxCriticalSection&amp; Lock() { return m_eventsLocker; }

    wxCriticalSection   m_eventsLocker;
#  else
    const wxCriticalSection&amp; Lock() const { return *m_eventsLocker; }
    wxCriticalSection&amp; Lock() { return *m_eventsLocker; }

    wxCriticalSection*  m_eventsLocker;
#  endif
#endif

    // Is event handler enabled?
    bool                m_enabled;

    // The user data: either an object which will be deleted by the container
    // when it's deleted or some raw pointer which we do nothing with - only
    // one type of data can be used with the given window (i.e. you cannot set
    // the void data and then associate the container with wxClientData or vice
    // versa)
    union
    {
        wxClientData *m_clientObject;
        void         *m_clientData;
    };

    // what kind of data do we have?
    wxClientDataType m_clientDataType;

    // client data accessors
    virtual void DoSetClientObject( wxClientData *data );
    virtual wxClientData *DoGetClientObject() const;

    virtual void DoSetClientData( void *data );
    virtual void *DoGetClientData() const;

private:
    DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler)
};
</code></pre>
<p>Wenn ihr noch was braucht, sagt Bescheid, ich werd auch weiterhin im Internet stöbern, aber wär toll, wenn jemand mir helfen könnte.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/250794/invalid-static-cast</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 20:53:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/250794.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Sep 2009 09:32:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to invalid static cast on Thu, 24 Sep 2009 09:32:07 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche gerade ein Programm zu kompilieren, dass ich zwar nicht selbst geschreiben habe, aber ein wenig umändern wollte. Nun sagt er mir aber Folgendes:</p>
<pre><code class="language-cli">maggy:CancerSim praktikant$ make -f makefile2.txt
g++  -c -O3  `/Users/praktikant/Desktop/wxMac-2.8.10/build-ansi/wx-config --cxxflags`  -c -o wxGLCanvas2.o wxGLCanvas2.cc
wxGLCanvas2.cc:25: error: invalid static_cast from type ‘void (wxGLCanvas2::*)()’ to type ‘void (wxEvtHandler::*)(wxEraseEvent&amp;)’
make: *** [wxGLCanvas2.o] Error 1
</code></pre>
<p>Da ich ziemlich neu mit c++ bin, bin ich leider überfragt mit dieser Fehlermeldung. Bisherige Lösungen aus dem Internet haben bei mir leider nicht funktioniert, aber ich hab auch noch nicht so viele durch...</p>
<p>Hier auf jeden Fall mal die Codes:<br />
<a href="http://wxGLCanvas2.cc" rel="nofollow">wxGLCanvas2.cc</a></p>
<pre><code class="language-cpp">#include &quot;wxGLCanvas2.h&quot;

BEGIN_EVENT_TABLE(wxGLCanvas2, wxGLCanvas)
  EVT_PAINT(wxGLCanvas2::OnPaint)
  EVT_ERASE_BACKGROUND(wxGLCanvas2::OnEraseBackground)  //&lt;-- hier ist Zeile 25
END_EVENT_TABLE()

wxGLCanvas2::wxGLCanvas2(wxWindow * parent, wxGLCanvas2_Render * render)
  : wxGLCanvas(parent,-1), m_render(render)
{

}

void wxGLCanvas2::OnPaint(wxPaintEvent &amp; e)
{
  wxPaintDC dc(this);
//  cout &lt;&lt; &quot;wxGLCanvas2::OnPaint&quot; &lt;&lt; endl;
  SetCurrent();
  m_render-&gt;render();
  SwapBuffers();
}
</code></pre>
<p>wxGLCanvas2.h</p>
<pre><code class="language-cpp">#include &quot;wx/wx.h&quot;
#include &quot;wx/glcanvas.h&quot;

class wxGLCanvas2_Render
{
public:
  virtual void render() = 0;
};

class wxGLCanvas2 : public wxGLCanvas
{
  DECLARE_EVENT_TABLE()

public:

  wxGLCanvas2(wxWindow * parent, wxGLCanvas2_Render*);

  void OnEraseBackground() { };
  void OnPaint(wxPaintEvent&amp;);

protected:
  wxGLCanvas2_Render * m_render;
};
</code></pre>
<p>und der Teil von event.h, wo wxEvtHandler drin ist (event.h wird über wx/wx.h includiert)</p>
<pre><code class="language-cpp">// ----------------------------------------------------------------------------
// wxEvtHandler: the base class for all objects handling wxWidgets events
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
{
public:
    wxEvtHandler();
    virtual ~wxEvtHandler();

    wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
    wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
    void SetNextHandler(wxEvtHandler *handler) { m_nextHandler = handler; }
    void SetPreviousHandler(wxEvtHandler *handler) { m_previousHandler = handler; }

    void SetEvtHandlerEnabled(bool enabled) { m_enabled = enabled; }
    bool GetEvtHandlerEnabled() const { return m_enabled; }

    // process an event right now
    virtual bool ProcessEvent(wxEvent&amp; event);

    // add an event to be processed later
    void AddPendingEvent(wxEvent&amp; event);

    void ProcessPendingEvents();

#if wxUSE_THREADS
    bool ProcessThreadEvent(wxEvent&amp; event);
#endif

    // Dynamic association of a member function handler with the event handler,
    // winid and event type
    void Connect(int winid,
                 int lastId,
                 int eventType,
                 wxObjectEventFunction func,
                 wxObject *userData = (wxObject *) NULL,
                 wxEvtHandler *eventSink = (wxEvtHandler *) NULL);

    // Convenience function: take just one id
    void Connect(int winid,
                 int eventType,
                 wxObjectEventFunction func,
                 wxObject *userData = (wxObject *) NULL,
                 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { Connect(winid, wxID_ANY, eventType, func, userData, eventSink); }

    // Even more convenient: without id (same as using id of wxID_ANY)
    void Connect(int eventType,
                 wxObjectEventFunction func,
                 wxObject *userData = (wxObject *) NULL,
                 wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { Connect(wxID_ANY, wxID_ANY, eventType, func, userData, eventSink); }

    bool Disconnect(int winid,
                    int lastId,
                    wxEventType eventType,
                    wxObjectEventFunction func = NULL,
                    wxObject *userData = (wxObject *) NULL,
                    wxEvtHandler *eventSink = (wxEvtHandler *) NULL);

    bool Disconnect(int winid = wxID_ANY,
                    wxEventType eventType = wxEVT_NULL,
                    wxObjectEventFunction func = NULL,
                    wxObject *userData = (wxObject *) NULL,
                    wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { return Disconnect(winid, wxID_ANY, eventType, func, userData, eventSink); }

    bool Disconnect(wxEventType eventType,
                    wxObjectEventFunction func,
                    wxObject *userData = (wxObject *) NULL,
                    wxEvtHandler *eventSink = (wxEvtHandler *) NULL)
        { return Disconnect(wxID_ANY, eventType, func, userData, eventSink); }

    wxList* GetDynamicEventTable() const { return m_dynamicEvents ; }

    // User data can be associated with each wxEvtHandler
    void SetClientObject( wxClientData *data ) { DoSetClientObject(data); }
    wxClientData *GetClientObject() const { return DoGetClientObject(); }

    void SetClientData( void *data ) { DoSetClientData(data); }
    void *GetClientData() const { return DoGetClientData(); }

    // check if the given event table entry matches this event and call the
    // handler if it does
    //
    // return true if the event was processed, false otherwise (no match or the
    // handler decided to skip the event)
    static bool ProcessEventIfMatches(const wxEventTableEntryBase&amp; tableEntry,
                                      wxEvtHandler *handler,
                                      wxEvent&amp; event);

    // implementation from now on
    virtual bool SearchEventTable(wxEventTable&amp; table, wxEvent&amp; event);
    bool SearchDynamicEventTable( wxEvent&amp; event );

#if wxUSE_THREADS
    void ClearEventLocker();
#endif // wxUSE_THREADS

    // Avoid problems at exit by cleaning up static hash table gracefully
    void ClearEventHashTable() { GetEventHashTable().Clear(); }

private:
    static const wxEventTableEntry sm_eventTableEntries[];

protected:
    // hooks for wxWindow used by ProcessEvent()
    // -----------------------------------------

    // This one is called before trying our own event table to allow plugging
    // in the validators.
    //
    // NB: This method is intentionally *not* inside wxUSE_VALIDATORS!
    //     It is part of wxBase which doesn't use validators and the code
    //     is compiled out when building wxBase w/o GUI classes, which affects
    //     binary compatibility and wxBase library can't be used by GUI
    //     ports.
    virtual bool TryValidator(wxEvent&amp; WXUNUSED(event)) { return false; }

    // this one is called after failing to find the event handle in our own
    // table to give a chance to the other windows to process it
    //
    // base class implementation passes the event to wxTheApp
    virtual bool TryParent(wxEvent&amp; event);

    static const wxEventTable sm_eventTable;
    virtual const wxEventTable *GetEventTable() const;

    static wxEventHashTable   sm_eventHashTable;
    virtual wxEventHashTable&amp; GetEventHashTable() const;

    wxEvtHandler*       m_nextHandler;
    wxEvtHandler*       m_previousHandler;
    wxList*             m_dynamicEvents;
    wxList*             m_pendingEvents;

#if wxUSE_THREADS
#if defined (__VISAGECPP__)
    const wxCriticalSection&amp; Lock() const { return m_eventsLocker; }
    wxCriticalSection&amp; Lock() { return m_eventsLocker; }

    wxCriticalSection   m_eventsLocker;
#  else
    const wxCriticalSection&amp; Lock() const { return *m_eventsLocker; }
    wxCriticalSection&amp; Lock() { return *m_eventsLocker; }

    wxCriticalSection*  m_eventsLocker;
#  endif
#endif

    // Is event handler enabled?
    bool                m_enabled;

    // The user data: either an object which will be deleted by the container
    // when it's deleted or some raw pointer which we do nothing with - only
    // one type of data can be used with the given window (i.e. you cannot set
    // the void data and then associate the container with wxClientData or vice
    // versa)
    union
    {
        wxClientData *m_clientObject;
        void         *m_clientData;
    };

    // what kind of data do we have?
    wxClientDataType m_clientDataType;

    // client data accessors
    virtual void DoSetClientObject( wxClientData *data );
    virtual wxClientData *DoGetClientObject() const;

    virtual void DoSetClientData( void *data );
    virtual void *DoGetClientData() const;

private:
    DECLARE_DYNAMIC_CLASS_NO_COPY(wxEvtHandler)
};
</code></pre>
<p>Wenn ihr noch was braucht, sagt Bescheid, ich werd auch weiterhin im Internet stöbern, aber wär toll, wenn jemand mir helfen könnte.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783476</guid><dc:creator><![CDATA[hello_c++]]></dc:creator><pubDate>Thu, 24 Sep 2009 09:32:07 GMT</pubDate></item><item><title><![CDATA[Reply to invalid static cast on Thu, 24 Sep 2009 09:37:27 GMT]]></title><description><![CDATA[<p>Zumindest die Argumenttypen sollten übereinstimmen:</p>
<pre><code>class wxGLCanvas2 : public wxGLCanvas
{
  DECLARE_EVENT_TABLE()

public:

  wxGLCanvas2(wxWindow * parent, wxGLCanvas2_Render*);

  [b]void OnEraseBackground(wxPaintEvent&amp;) { }[/b]
  void OnPaint(wxPaintEvent&amp;);

protected:
  wxGLCanvas2_Render * m_render;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1783480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783480</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 24 Sep 2009 09:37:27 GMT</pubDate></item><item><title><![CDATA[Reply to invalid static cast on Thu, 24 Sep 2009 12:12:43 GMT]]></title><description><![CDATA[<p>oh, ist mir gar nicht aufgefallen, hab ich geändert, ist aber immernoch der selbe Fehler...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783544</guid><dc:creator><![CDATA[hello_c++]]></dc:creator><pubDate>Thu, 24 Sep 2009 12:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to invalid static cast on Thu, 24 Sep 2009 12:31:07 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Zumindest die Argumenttypen sollten übereinstimmen:</p>
<pre><code>[b]void OnEraseBackground(wxPaintEvent&amp;)[/b]
</code></pre>
</blockquote>
<p>void OnEraseBackground(<strong>wxEraseEvent&amp;</strong>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783548</guid><dc:creator><![CDATA[me_s]]></dc:creator><pubDate>Thu, 24 Sep 2009 12:31:07 GMT</pubDate></item><item><title><![CDATA[Reply to invalid static cast on Fri, 25 Sep 2009 11:11:42 GMT]]></title><description><![CDATA[<p>Super, hat alles geklappt, waren ja auch doofe Fehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Danke nochmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1784074</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1784074</guid><dc:creator><![CDATA[hello_c++]]></dc:creator><pubDate>Fri, 25 Sep 2009 11:11:42 GMT</pubDate></item></channel></rss>