From: Jeremia B. <je...@je...> - 2013-01-21 22:57:43
|
Hi, I looked at liblo for the first time today. I had some problems getting the example codes to run until I realized this is because of a subtle difference of C and C++. In 'example_server.c', line 82 lo_arg_pp(types[i], argv[i]); (where types is of 'const char*') compiles nicely as C code using gcc. Using the same code from C++ however, compiling with g++, yields the following compiling error: examples/example_server.c: In function ‘int generic_handler(const char*, const char*, lo_arg**, int, void*, void*)’: examples/example_server.c:82:36: error: invalid conversion from ‘char’ to ‘lo_type’ examples/example_server.c:82:36: error: initializing argument 1 of ‘void lo_arg_pp(lo_type, void*)’ Researching I found this: In C, an enum (e.g. lo_type) is always of type int. Thus, an implicit type-cast is performed. In C++, enum is a distinct type and implicit conversion is not allowed. Making the cast explicit makes the code work in both C and C++, like so: lo_arg_pp((lo_type) types[i], argv[i]); Now I see that this is an example C code and maybe even a C++ programmer should be aware of that difference. But it's quite nasty so I'd suggest changing the example code to the above line or add a comment for naive C++ programmers like I am ;-) I very much like liblo. It's very straightforward. Regrads, Jeremia |