Hello,
I am trying to compile macros with c++14/17 features, either with g+±9
g++-9 -std=c++17 -o simulation.exe particle.cpp main-particle.C `root-config --cflags --libs`
or with ACLiC
.L particle.cpp+
.L main-particle.C+
Building ROOT was my first experience with CMake and I did not set the flag -Dcxx17=ON. Having used inline variables, fold expressions and deduced return types, I get error messages and warnings. I notice the flag -std=c++17 is ignored, possibly because of root-config which comes after and sets c++11 support. Therefore I tried putting it at the end of the command, which results in compile errors in several ROOT headers, starting from:
In file included from /home/kimdamiani/Products/root/include/TString.h:28,
from /home/kimdamiani/Products/root/include/TNamed.h:26,
from /home/kimdamiani/Products/root/include/TRandom.h:25,
from main-particle.C:2:
/home/kimdamiani/Products/root/include/ROOT/RStringView.hxx:32:10: error: conflicting declaration of template ‘template<class _CharT, class _Traits> using basic_string_view = std::experimental::__ROOT::basic_string_view<_CharT, _Traits>’
32 | using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
| ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/basic_string.h:48,
from /usr/include/c++/9/string:55,
from /usr/include/c++/9/bits/locale_classes.h:40,
from /usr/include/c++/9/bits/ios_base.h:41,
from /usr/include/c++/9/ios:42,
from /usr/include/c++/9/ostream:38,
from /usr/include/c++/9/iostream:39,
from main-particle.C:1:
/usr/include/c++/9/string_view:90:11: note: previous declaration ‘template<class _CharT, class _Traits> class std::basic_string_view’
90 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
-the list goes on.
Is there any other flag I can add when compiling my macros or is deleting ROOT and building it again with -Dcxx17=ON the only option to support c++14/17 features?
Thank you in advance,
Kim
_ROOT Version: 6.18/04
_Platform: Ubuntu 19.04 x86_64