Using callbacks is surely the easiest way of handling timer events I would have thought.
In C this never was a problem but for some reason it's become more difficult to do than before in c++. I don't exactly see why it would be terrible to abstract a lot of hardware functions but the challenge is getting them from the C style operating system type notations into higher level C++ with object orientation. The other alternative is to have hundreds/thousands of lines of code with multiple entry points (interrupts/signals) which can equally be terrible to debug. On 26/04/2014 11:17 am, "Jiří Baum" <j...@baum.com.au> wrote: > Hi, > > David Lyon: > > When I compile, I get these errors: > > > dlyon@dlyon-HP8000SFF:~/IoT/madstuff$ make > > CC madstuff.o > > madstuff.cpp: In member function ‘void App::setup()’: > > madstuff.cpp:33:45: warning: converting from ‘void (App::*)()’ to ‘void > > (*)()’ [-Wpmf-conversions] > > addTimerEvent(2, (void (*)()) &App::timerevent); > > A quick Google suggests that converting a pointer to a bound method to a > function pointer is a terrible, non-standard thing to do... They're > about evenly split between suggesting you don't do that, and suggesting > you use -Wno-pmf-conversions to suppress the warning. > > The thing is, a pointer to a bound method needs to contain not just the > function pointer but also information about the "this" pointer and about > the virtual table; converting it to a plain pointer throws all that > information away. Only gcc will even let you do that (and still call the > function afterwards). > > So, if there's an easy way to avoid it, don't do that. Otherwise, if > you're happy with being gcc-specific, you can suppress the warning. > > > Cheers > > Jiri > -- > Jiří Baum <j...@baum.com.au> > Sabik Software Solutions Pty Ltd > 0413 183 117 > http://www.baum.com.au/sabik > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html