radarsat1 / liblo

liblo is an implementation of the Open Sound Control protocol for POSIX systems
GNU Lesser General Public License v2.1
192 stars 60 forks source link

Feature request: lo_send as a 'real' function, not a macro #73

Closed zeekoe closed 5 years ago

zeekoe commented 5 years ago

I tried accessing liblo from Java using JNA (Java Native Access), but after a lot of wrestling with liblo I wrote my own wrapper lib. It turned out that the problem was, that lo_send is a macro and not a real function (https://stackoverflow.com/questions/54845785/linux-jna-unsatisfiedlinkerror-on-liblo-second-method-call/54877483#54877483). I'm not very much into C; is there a good reason not to convert it to a 'real' function to have other languages access liblo more easily?

radarsat1 commented 5 years ago

The original author wrote it like that to automatically append the MARKER_A and MARKER_B special codes to help detect vararg-related errors. There's no easy way to fix it without breaking existing user code unfortunately so I've opted to leave it. (I might remove it if I ever release a "breaking" major version.) You could wrap lo_send_internal instead but in fact due to the use of varargs I recommend bindings to use lo_message_add et al, and lo_message_send instead of lo_send_internal.

zeekoe commented 5 years ago

Thanks for your clear answer. I understand the difficulties. Using the lo_message_add* might indeed be a good option for me when I want to implement more functionality (e.g. receiving messages) from liblo, or I'll just keep the small wrapper if I'm lazy. :)