Enable C++23 in ROOT 6.34.00-rc1

  • ROOT Version: 6.34.00-rc1
  • Platform: Linux
  • Compiler: GCC 13

Since LLVM 18 support C++ 23, I tried to enable it in 6.34.00-rc1.

I have done the following things:

  • set -DCMAKE_CXX_STANDARD=23 when building ROOT.
  • Patch source file of ROOT (around line 164 of file cmake/modules/CheckCompiler.cmake, sorry I could not post hyperlink as a new user), to make it successfully configured.

Finally I get a working ROOT. root-config --cflags print:

-pthread -std=c++23 -m64 -I/nix/store/ziqv1agc2m39xg1d2awiqdi4v9sjgxwz-root-6.34.00-rc1/include

However, when I run the following code in ROOT (which utilized a C++23 feature):

auto a = [](this auto self) {}

ROOT complained:

ROOT_prompt_0:1:13: error: explicit object parameters are incompatible with C++ standards before C++2b
auto a = [](this auto self) {}

It seems -std=c++23 was not passed to underling cling. How could I modify flags passed to cling?

This will probably not help: is ROOT_CXX_STANDARD also set to 23 ?

No, I did not know this variable. I will try it now.

It seems this variable is only useful when using ROOT with CMake (not when building root), and this variable is actually used to set default CMAKE_CXX_STANDARD. But I am using the interpreter of ROOT.

I think the problem might be in file: cling/lib/Interpreter/CIFactory.cpp at master · root-project/cling · GitHub

  • Search at several places for ‘case 20’ and add also a ‘case 23’.
  • Patch the function CxxStdCompiledWith

If you manage to make it work, feel free to open a PR, splitting commits that modify interpreter/ from others.

I managed to make it works, with some additional fix.
Should I split the pr into two, one for Cling repository at GitHub, and another for ROOT repository at GitHub, or just submit a single pr to ROOT repository?

A single one at ROOT repo, with independent commits for everything within interpreter/* folders.

Thanks. I have created a pr 17253.

2 Likes