c++ - VS 2015 and FLTK Callback issue -


i trying move fltk projects , compile under vs 2015 community edition. while this, getting error. have code below:

#include <fl/....> .... class cwindow { private:     ....     fl_input *_textinputeditor;     ....     void _cbtextinput(fl_widget *refobject, void *objdata)     {         // when callback triggered.     } public: ....     void createwindow()     {         ....         _textinputeditor = new fl_input(....);         _textinputeditor->when(fl_when_enter_key);         _textinputeditor->callback((fl_callback*)&cwindow::_cbtextinput, this);         .... 

when try compile, error:

error c2440 'type cast': cannot convert 'void (__thiscall cwindow::* )(fl_widget *,void *)' 'fl_callback (__cdecl *)

this same code compiles mingw 5.x (ide: c::b) under win 7.

can me here? want call private method of cwindow class.

the signature incorrect. _cbtextinput should static. problem access member variables.

static void _cbtextinput(fl_widget *refobject, void *objdata) {     // no access member variables cast cwindow*     // @ member variables     cwindow* self = (cwindow*) objdata;     self->cbtextinput();      // alternatively, if not wish write routine,     // need put self-> in front of every member variable     // wish access.  personal preference: people prefer     // way. }  void cbtextinput() {     // has access member variables     ... } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -