C++11 support

Hi, I built the git master of Root to try cling. I noticed that the root shell does not support C++11 headers:

$ root -n
root [0] #include <unordered_map>
In file included from input_line_25:1:
In file included from /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/unordered_map:35:
/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
 ^
root [1]

However, I found on the web that cling has options to turn on C++11 support: -Wc++11-extensions -std=c++11. I was wondering whether it is possible to use C++11 also with the root shell, I tried to pass the cling options to root but obviously without success…

Hi,

try recompiling ROOT with:

./configure --with-cxx11

– Fons

Thanks Fons, I get this error (using today’s git master):

Invalid option '--with-cxx11'. Try ../root-git/configure --help

With --enable-c++11 it correctly configures the c++11 support:

Enabled support for asimage, astiff, bonjour, builtin_afterimage, builtin_ftgl, builtin_llvm, cxx11, explicitlink, fftw3, gdml, genvector, krb5, ldap, memstat, minuit2, mysql, odbc, opengl, python, shadowpw, shared, ssl, tmva, x11, xft, xml.

I did it before and cling didn’t work with C++11 headers. I tried again today but now I get this compilation error:

Generating dictionary core/base/src/G__Core.cxx...
[...]
In file included from G__Core.cxx.h:1:
In file included from input_line_2:1:
In file included from etc/cling/Interpreter/ValuePrinter.h:11:
In file included from /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/string:40:
In file included from /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/bits/char_traits.h:39:
In file included from /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/bits/stl_algobase.h:64:
In file included from /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/bits/stl_pair.h:59:
In file included from /usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/bits/move.h:57:
/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/type_traits:269:39: error: use of undeclared identifier '__float128'
    struct __is_floating_point_helper<__float128>
                                      ^
make: *** [core/base/src/G__Core.cxx] Segmentation fault (core dumped)
make: *** Deleting file `core/base/src/G__Core.cxx'

so I can’t test it further.

Hi,

Thanks, fixed in the head of the master!

Axel.

Thanks Axel, with your fix the compilation error has gone away. Now cling includes the header for unordered_map without any problem, so also my original problem is solved! Thanks also to Fons!

For the benefit of other people: in the land of cmake, the corresponding invocation is:
cmake -Dcxx11=ON $PATH_TO_SOURCE

And just for the record, with autoconf, the correct flag ist
$PATH_TO_SOURCE/configure --enable-cxx11
(not ‘–with-cxx11’ as said above).