YunTianZhou/GLBLib

Compiling error: invalid conversion from ‘void (*)(int)’ to ‘void*’

Opened this issue · 0 comments

Got the following compiling error when build the second example:

zhoumg@ddttgg:~/src/glblib/triangle/build$ make
[ 50%] Building CXX object CMakeFiles/tri.dir/main.cpp.o
/home/zhoumg/src/glblib/triangle/main.cpp: In function ‘int main()’:
/home/zhoumg/src/glblib/triangle/main.cpp:82:60: error: invalid conversion from ‘void (*)(int)’ to ‘void*’ [-fpermissive]
   82 |     glb::Cursor::SetCallback(glb::Cursor::Callback::Enter, OnCursorEnter);
      |                                                            ^~~~~~~~~~~~~
      |                                                            |
      |                                                            void (*)(int)
In file included from /home/zhoumg/src/glblib/GLBLib/include/GLB/GLB.h:28,
                 from /home/zhoumg/src/glblib/triangle/main.cpp:3:
/home/zhoumg/src/glblib/GLBLib/include/GLB/Cursor.h:59:54: note:   initializing argument 2 of ‘static bool glb::Cursor::SetCallback(Callback, void*)’
   59 |         static bool SetCallback(Callback type, void* callback);
      |                                                ~~~~~~^~~~~~~~
/home/zhoumg/src/glblib/triangle/main.cpp:83:66: error: invalid conversion from ‘void (*)(int, int, int)’ to ‘void*’ [-fpermissive]
   83 |     glb::Cursor::SetCallback(glb::Cursor::Callback::MouseButton, OnMouseButton);
      |                                                                  ^~~~~~~~~~~~~
      |                                                                  |
      |                                                                  void (*)(int, int, int)
/home/zhoumg/src/glblib/GLBLib/include/GLB/Cursor.h:59:54: note:   initializing argument 2 of ‘static bool glb::Cursor::SetCallback(Callback, void*)’
   59 |         static bool SetCallback(Callback type, void* callback);
      |                                                ~~~~~~^~~~~~~~
/home/zhoumg/src/glblib/triangle/main.cpp:86:52: error: invalid conversion from ‘void (*)(int, int, int, int)’ to ‘void*’ [-fpermissive]
   86 |     glb::Key::SetCallback(glb::Key::Callback::Key, +[](int key, int, int, int) {
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    void (*)(int, int, int, int)
   87 |         std::cout << "Key pressed: " << key << std::endl;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   88 |         });
      |         ~                                           
In file included from /home/zhoumg/src/glblib/GLBLib/include/GLB/GLB.h:34:
/home/zhoumg/src/glblib/GLBLib/include/GLB/Key.h:171:62: note:   initializing argument 2 of ‘static bool glb::Key::SetCallback(Callback, void*)’
  171 |                 static bool SetCallback(Callback type, void* callback);
      |                                                        ~~~~~~^~~~~~~~
/home/zhoumg/src/glblib/triangle/main.cpp:102:54: error: invalid conversion from ‘void (*)()’ to ‘void*’ [-fpermissive]
  102 |     window.SetCallback(glb::Window::Callback::Close, OnWindowClose);
      |                                                      ^~~~~~~~~~~~~
      |                                                      |
      |                                                      void (*)()
In file included from /home/zhoumg/src/glblib/GLBLib/include/GLB/GLB.h:22:
/home/zhoumg/src/glblib/GLBLib/include/GLB/Window.h:36:47: note:   initializing argument 2 of ‘bool glb::Window::SetCallback(Callback, void*)’
   36 |         bool SetCallback(Callback type, void* callback);
      |                                         ~~~~~~^~~~~~~~
/home/zhoumg/src/glblib/triangle/main.cpp:105:57: error: invalid conversion from ‘void (*)(int, int)’ to ‘void*’ [-fpermissive]
  105 |     window.SetCallback(glb::Window::Callback::Position, +[](int xpos, int ypos) {
      |                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                         |
      |                                                         void (*)(int, int)
  106 |         std::cout << "Window position: " << xpos << ", " << ypos << std::endl;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107 |         });
      |         ~                                                
/home/zhoumg/src/glblib/GLBLib/include/GLB/Window.h:36:47: note:   initializing argument 2 of ‘bool glb::Window::SetCallback(Callback, void*)’
   36 |         bool SetCallback(Callback type, void* callback);
      |                                         ~~~~~~^~~~~~~~
make[2]: *** [CMakeFiles/tri.dir/build.make:76: CMakeFiles/tri.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/tri.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
zhoumg@ddttgg:~/src/glblib/triangle/build$