rafalcieslak / harmonySEQ

MIDI sequencer designed for live performances
https://harmonyseq.wordpress.com/
GNU General Public License v3.0
11 stars 2 forks source link

Callbacks of type lo_message_handler have the wrong signature #11

Closed musicinmybrain closed 7 months ago

musicinmybrain commented 7 months ago

As part of the PortingToModernC Change in Fedora, packages are built with the equivalent of -Werror=incompatible-pointer-types.

This causes harmonySEQ to fail to build from source. The problem is that the fifth parameter in the lo_method_handler function-pointer typedef is lo_message_*, i.e., lo_message

https://github.com/radarsat1/liblo/blob/c1a51bca21e8535ce77a9daf256f2e74c1a7e80f/lo/lo_types.h#L134-L136

but the handlers in OSC.cpp define it as void *, which likely has the same representation on POSIX-compliant systems, but which makes the function pointer incompatible in strict C++ standard terms.

Note that this behavior is expected to become the default in GCC at some point, possibly in GCC 14, so this could eventually affect a larger number of users.

PR to follow.

/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp: In function ‘void RunOSCThread()’:
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:97:60: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
   97 |     lo_server_thread_add_method(st,"/harmonyseq/event","i",events_handler,NULL);
      |                                                            ^~~~~~~~~~~~~~
      |                                                            |
      |                                                            int (*)(const char*, const char*, lo_arg**, int, void*, void*)
In file included from /usr/include/lo/lo.h:33,
                 from /builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:27:
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:98:61: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
   98 |     lo_server_thread_add_method(st,"/harmonyseq/triger","i",events_handler,NULL);
      |                                                             ^~~~~~~~~~~~~~
      |                                                             |
      |                                                             int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:99:61: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
   99 |     lo_server_thread_add_method(st,"/harmonyseq/pause",NULL,pause_handler,NULL);
      |                                                             ^~~~~~~~~~~~~
      |                                                             |
      |                                                             int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:100:60: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
  100 |     lo_server_thread_add_method(st,"/harmonyseq/play",NULL,unpause_handler,NULL);
      |                                                            ^~~~~~~~~~~~~~~
      |                                                            |
      |                                                            int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:101:63: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
  101 |     lo_server_thread_add_method(st,"/harmonyseq/unpause",NULL,unpause_handler,NULL);
      |                                                               ^~~~~~~~~~~~~~~
      |                                                               |
      |                                                               int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:102:60: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
  102 |     lo_server_thread_add_method(st,"/harmonyseq/tempo","f",tempo_handler,NULL);
      |                                                            ^~~~~~~~~~~~~
      |                                                            |
      |                                                            int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:103:60: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
  103 |     lo_server_thread_add_method(st,"/harmonyseq/sync",NULL,sync_handler,NULL);
      |                                                            ^~~~~~~~~~~~
      |                                                            |
      |                                                            int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:104:67: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
  104 |     lo_server_thread_add_method(st,"/harmonyseq/synchronize",NULL,sync_handler,NULL);
      |                                                                   ^~~~~~~~~~~~
      |                                                                   |
      |                                                                   int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^
/builddir/build/BUILD/harmonySEQ-0.17/src/OSC.cpp:105:46: error: invalid conversion from ‘int (*)(const char*, const char*, lo_arg**, int, void*, void*)’ to ‘lo_method_handler’ {aka ‘int (*)(const char*, const char*, lo_arg**, int, lo_message_*, void*)’} [-fpermissive]
  105 |     lo_server_thread_add_method(st,NULL,NULL,generic_handler,NULL);
      |                                              ^~~~~~~~~~~~~~~
      |                                              |   
      |                                              int (*)(const char*, const char*, lo_arg**, int, void*, void*)
/usr/include/lo/lo_serverthread.h:151:72: note:   initializing argument 4 of ‘lo_method_* lo_server_thread_add_method(lo_server_thread, const char*, const char*, lo_method_handler, const void*)’
  151 |                                const char *typespec, lo_method_handler h,
      |                                                      ~~~~~~~~~~~~~~~~~~^