C++11 Library Support Through ACLiC

Hi, I am trying to get my ROOT code to compile with ACLiC, but it uses some C++11 features that depend on the libc++/libstdc++ thing. C++11 language features work fine (auto, range-based for loops, lambdas), but for example I cannot use list initializers for vectors.

I am using root compiled from MacPorts on OSX 10.7.5. I am using the variant built with clang 3.2, and I have been trying (without success) to follow the partial instructions here: trac.macports.org/ticket/39975 to get their experimental support working.

Has anyone succeeded at getting a simple list-initialized vector to compile using ACLiC on OSX? Is my two year old MacBook really too old to support C++11, or is there a simple fix?

Jean-François

I realize this post is a month old, but I’ve had exactly the same issue: no success using list initialization with vectors.

If I use the “old” = notation, i.e.:

std::vector V = {1,2,3};

I get the error:

error: non-aggregate type ‘std::vector’ cannot be initialized with an initializer list.

If I use the new-in-C++11 notation:

std::vector V {1,2,3};

I get the error:

error: expected ‘;’ at end of declaration std::vector V {1,2,3};

(The second error comes whenever I try to use list initialization, i.e. curly braces, for any type.) Is this a known limitation, and something we shouldn’t expect changed until Root 6? Or should this work? If the latter, perhaps it’s relevant that when I try to #include <initializer_list>, I get a slew of errors, most of this form:

Error: Unexpected end of file (G__fgetname():2) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…
/lib/c++/v1/__config:3:

The errors mentioned earlier, however, come when I remove the <initializer_list> include directive. Unlike the OP, I’m running Root 5.34.11 cloned from github, with ./cofigure --all --with-finkdir=/usr/local/bin/brew. The machine is an Ivy Bridge rMBP, with OS X 10.9.

Any feedback appreciated,
Patrick

Apparently OSX comes with different C++ runtimes depending on the version. 10.9 uses the newer one that does list-initialization, while <=10.8 use the older runtime that doesn’t.

I tried to get MacPorts people to help out with getting full C++11 support for my 10.7.5 machine, but they were only able to make it work for people on 10.9 or later: trac.macports.org/ticket/39975

Jean-François

I can’t speak to issues with MacPorts, but I did just confirm that initializer lists do work for vectors (and presumably other types for which they’re defined). It was my careless error: I had thought ./configure --all would in effect --enable-cxx11, since it does in effect --enable-libcxx, but I didn’t check closely enough. Including --enable-cxx11 does the trick…

Jean-François, I apologize for muddying the issue raised in your original post. 10.9 was the first to ship with libc++ instead of libstdc++. (There are other more detailed posts about this elsewhere on these fora.) But to my knowledge, both versions of the standard library should support list initialization since both must comply with the ISO standards for C++11. Is upgrading to 10.9 (free, at least for those with 10.8), or downloading/compiling Root via github, out of the question?

Patrick

I don’t really want to upgrade my whole OS until I absolutely need to, as I’ve grown to live with 10.7’s idiosyncrasies. Honestly if I was going to upgrade the OS, I’d switch back to linux, but it’d be a whole lot fo work to get set up and productive again.

I generally prefer getting my programs from MacPorts, since it automatically gets updates for me and such. I could probably compile my own ROOT (indeed I have both C++ runtimes somewhere in the system), but I like keeping everything under the same packager. Lack of full C++11 support isn’t quite a deal-breaker for me yet.

Jean-François