# Enable C++23 in ROOT 6.34.00-rc1

**URL:** <https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433>\
**Category:** Newbie\
**Created:** [December 10, 2024, 4:47pm UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433 "2024-12-10T16:47:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CHN-beta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chn-beta/32/38075_2.png) [@CHN-beta](https://root-forum.cern.ch/u/CHN-beta)\
**Post date:** [December 10, 2024, 4:47pm UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/1 "2024-12-10T16:47:26Z")

</div>

- 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:

```auto
-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
auto a = [](this auto self) {}

```

ROOT complained:

```auto
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?

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [December 10, 2024, 6:29pm UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/2 "2024-12-10T18:29:10Z")

</div>

This will probably not help: is ROOT\_CXX\_STANDARD also set to 23 ?

---

<div class="post-metadata">

**Author:** ![CHN-beta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chn-beta/32/38075_2.png) [@CHN-beta](https://root-forum.cern.ch/u/CHN-beta)\
**Post date:** [December 11, 2024, 1:40am UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/3 "2024-12-11T01:40:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CHN-beta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chn-beta/32/38075_2.png) [@CHN-beta](https://root-forum.cern.ch/u/CHN-beta)\
**Post date:** [December 11, 2024, 1:44am UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/4 "2024-12-11T01:44:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [December 11, 2024, 8:16am UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/5 "2024-12-11T08:16:34Z")

</div>

I think the problem might be in file: [cling/lib/Interpreter/CIFactory.cpp at master · root-project/cling · GitHub](https://github.com/root-project/cling/blob/master/lib/Interpreter/CIFactory.cpp)

- 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.

---

<div class="post-metadata">

**Author:** ![CHN-beta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chn-beta/32/38075_2.png) [@CHN-beta](https://root-forum.cern.ch/u/CHN-beta)\
**Post date:** [December 11, 2024, 2:01pm UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/6 "2024-12-11T14:01:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [December 11, 2024, 2:15pm UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/7 "2024-12-11T14:15:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CHN-beta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/chn-beta/32/38075_2.png) [@CHN-beta](https://root-forum.cern.ch/u/CHN-beta)\
**Post date:** [December 11, 2024, 3:03pm UTC](https://root-forum.cern.ch/t/enable-c-23-in-root-6-34-00-rc1/62433/8 "2024-12-11T15:03:05Z")

</div>

Thanks. I have created a pr 17253.
