|
From: Stephen S. <rad...@gm...> - 2013-08-07 10:24:13
|
Now works with clang++ ! Tested with clang++ 3.2.1 on Ubuntu 13.04, and clang++ 4.2 on OS X 10.8.4. On Mac, I get an error message on running cpp_test, looking into it. Steve On Tue, Aug 6, 2013 at 2:18 PM, Stephen Sinclair <rad...@gm...> wrote: > I forgot to mention that I have only been testing these bindings with > my Ubuntu 13.04 install. I have just found problems trying to get it > working on my Mac. > > Here is how you can get past "configure" on OS X 10.8.4: > > ./configure CC=clang CXX="clang++ -stdlib=libc++" > ... > checking whether C++11 lambdas are supported... yes > ... > > Unfortunately it still results in a bunch of compilation errors with > clang++, not sure if that's due to my own semantic errors or due to > incomplete C++11 support. I'll have to look into it. In the meantime > I recommend playing around with minimum version g++ 4.7 if you're > interested in trying it. > > Steve > > > On Mon, Aug 5, 2013 at 6:29 PM, Stephen Sinclair <rad...@gm...> wrote: >> Hi everyone, >> >> I'd like to announce a "ready" version of the C++11 bindings for liblo >> that I've been working on for some time now. It is available in my >> "cpp" branch on github. >> >> You can check out the "test" program here, which gives a bunch of >> examples of how it can be used: >> >> https://github.com/radarsat1/liblo/blob/cpp/src/cpp_test.cpp >> >> In particular, it supports the following features: >> >> * Class-encapsulated access to liblo data structures (e.g. >> lo::Message, lo::Server, etc...) >> >> * Assign any kind of "callable" as a method handler >> - normal functions >> - function objects ("functors") >> - lambdas >> >> * Method handlers may declare only the arguments actually needed >> >> * Method handlers need not have a return value, defaults to adding >> "return 0" if your method handler returns void (return-type >> polymorphism!) >> -- (this decision was based on the idea that "return 0" is most >> commonly used.. not based on a scientific survey! feel free to >> disagree.) >> >> * Construct bundles and messages using static initializer lists >> >> * Polymorphism when adding data to messages >> >> This is all implemented in lo/lo_cpp.h, seen here: >> >> https://github.com/radarsat1/liblo/blob/cpp/lo/lo_cpp.h >> >> It's pretty complicated, requiring a bunch of macro-fu, so if you have >> any questions don't hesitate. (I would have preferred using only >> templates but some of these tricks seemed impossible without help from >> macros.) >> >> I think you'll enjoy using liblo through C++11. Here's an example of >> a method handler declaration: >> >> s.add_method("test12", "i", [j](const lo::Message m) >> {printf("test12 source: %s\n", m.source().url().c_str());}); >> >> Here's an example of constructing a bundle and sending it in one line of code: >> >> a.send( >> lo::Bundle({ >> {"test11", lo::Message("is",20,"first in bundle")}, >> {"test11", lo::Message("is",30,"second in bundle")} >> }) >> ); >> >> Enjoy, and please test, let me know what you think, etc. >> >> I've tried hard to make sure memory is handled right, but still >> occasionally find problem cases. It's a bit tricky and depends >> heavily on the new refcount feature for messages and bundles. There >> could definitely still be bugs but I have been exercising it quite a >> lot. Especially tell me if you encounter a "double-free" segfault. >> >> (For instance, one thing to know is that "lo::Message(lo::Message(m))" >> constructs two wrappers around "lo_message m", but does not copy the >> memory, they both refer to the same lo_message. This means you must >> use lo::Message::clone() to keep a message passed to a handler.) >> >> Steve |