ROOT/RStringView.hxx:67:17: error: expected type-specifier

Dear experts,

while trying to migrate a custom piece of code on to a new SL7 machine (amd64)
I have a problem that on first look seems to be related to the ROOT version. This looks like:

//cvmfs/cms.cern.ch/slc7_amd64_gcc900/lcg/root/6.18.04/include/ROOT/RStringView.hxx:67:17: error: expected type-specifier
67 | operator std::string_view() const { return std::string_view(fData,fLength); }

and appears multiple times during the compilation time. I would like to understand the origin of this and if possible to get a remedy.

Thank you,
Alexandros

_ROOT Version: 6.18.04
_Platform: slc7 (amd64)
_Compiler: gcc 9.3.0


The “std::string_view” requires at least C++17 so you are missing e.g. “-std=c++17” when compiling your source code (try “root-config --cflags”).

Hi Coyote,

actually I am using the following (partial) flag:
g++ -O2 -Wall -Wno-unused-local-typedefs -fPIC -D_REENTRANT -pthread -std=c++17 -m64 -I//cvmfs/cms.cern.ch/slc7_amd64_gcc900/lcg/root/6.18.04/include …

wouldn’t that cover it?
Cheers,
Alexandros

Make sure that the ROOT version, that you use, also has the C++17 flag among “root-config --cflags".

Hi Coyote,

this is what I get:
|> root-config --cflags
-pthread -std=c++17 -m64 -I//cvmfs/cms.cern.ch/slc7_amd64_gcc900/lcg/root/6.18.04/include

Correction,

i doubled checked again and there were certain cases (exceptions) where the flag -std=c++0x
was used instead of -std=c++17. I fixed it and now it compiles fine. I believe we can now close this thread.

Thank you,
Alexandros

Nice to hear! Note that RStringView.hxx provides a backport of std::string_view to C++11 (which just falls back to std::string_view if ROOT is compiled with at least C++17) – but mixing C++ standards is a no go.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.