pass function point as argument C++

Hello Thanks for taking a look.

Trying to pass a function pointer as an argument. The compiler is reporting invalid conversion. Using g++ compiler on linux with openGL library.
Any advice would be helpful. Can also provide more code if helpful.

defined in header file
SystemClass {
<snip>
static bool WaitForMapNotify (Display * d, XEvent * e, char *arg);
<snip>
};

dininded in cpp file
bool SystemClass::WaitForMapNotify (Display * d, XEvent * e, char *arg)
{
return d && e && arg && (e->type == MapNotify)
&& (e->xmap.window == *(Window *) arg);
}

Trying to pass the function...
void SystemClass::createTheWindow ()
{
<snip>
XIfEvent (Xdisplay, &event, &WaitForMapNotify, (char *)window_handle);
</snip>
}

compiler error message:
systemclass.cpp:152:71: error: invalid conversion from ‘bool (*)(Display*, XEvent*, char*) {aka bool (*)(_XDisplay*, _XEvent*, char*)}’ to ‘int (*)(Display*, XEvent*, XPointer) {aka int (*)(_XDisplay*, _XEvent*, char*)}’ [-fpermissive]
XIfEvent (Xdisplay, &event, &WaitForMapNotify, (char *)window_handle);





The compilation error is clear: the expected return type is int while the return type you have is bool
Last edited on
Yep, change return type to int and it works. Thought i did this way back many hours ago.
thx for the sanity check.
I returned it back to bool and it magically compiles. Not sure what the problem was but I make a wholesale list of changes. Anyway trying to write objects to initialize OpenGL with X11 is a bear. I am probably going to add glfw.
If you code you posted is written by you, you may want to consider eliminating your excessive use of pointers:
http://www.LB-Stuff.com/pointers
I believe XlFEvent is somewhat depricated. I have discovered more graceful ways to manage an event loop. Thank you for your time.
Topic archived. No new replies allowed.