Little test programm breaks at compile time...

Hello guys,

I have a such problem that I don't know if it will be well explained... The question is that I need to collect all X keyboard layouts and variants and I just meet xklavier library. I tried to write an object-oriented test C++ programm (while the project test programm is not object-oriented...) but the compiler (ie, g++) breaks when xkl_config_registry_foreach_language() is called, throwing this message:

....cc: In constructor ‘MyClass::MyClass()’:
....cc: error: argument of type ‘void (Teclat::)(XklConfigRegistry*, const XklConfigItem*, void*)’ does not match ‘void (*)(XklConfigRegistry*, const XklConfigItem*, void*)’


I don't find anywhere an specific xklavier forum to post this question, so I don't know if you can help me. Although, I wonder...

What does void (*) means ?

Thanks,

S.




It is referring to a pointer to a function which returns void and takes the three parameters.

It looks like you are trying to use a pointer to a member function where something is expecting a pointer to a non-member (free) function.

Jsmith,

Thanks, again. That's it.

Is there any way to call these non-member functions as member functions ?

S.
The typical approach is to make the callback function a static member function. This solves
the type mismatch problem, but now you need an instance of the object. Typically it is
passed to the callback via a void* parameter. I don't know the details of the above code,
but I would guess that that is exactly what the void* parameter is for in the callback function.
Thanks, jsmith,

I'll be it in mind.

S.
Topic archived. No new replies allowed.