I’m trying to build cairomm for gtkmm on windows using mingw. Compilation breaks at a function call which has a parameter which does a reinterpret_cast of a bool to a void*.
cairo_font_face_set_user_data(cobj(), &USER_DATA_KEY_DEFAULT_TEXT_TO_GLYPHS, reinterpret_cast<void*>(true), NULL);
This is where the code breaks, and reason is ‘invalid reinterpret_cast from bool to void*’. Why is this happening, and how can I modify this line to get it to compile? Need help
I see this is user data and you have control over what is done with the value, cast the bool to an int first:
reinterpret_cast<void *> (static_cast<int> (true)). Doing this makes sense in that the void* parameter takes the place of template functions in this ANSI-C library. All you need is a true/false value. So, there should be no danger in temporarily encoding this as a pointer as long as it is well documented as such. Really, you would be better off with this:reinterpret_cast<void *> (1)orreinterpret_cast<void *> (+true).