# Bugs in "TFile" when using C++17?

**URL:** <https://root-forum.cern.ch/t/bugs-in-tfile-when-using-c-17/40168>\
**Category:** Newbie\
**Created:** [July 1, 2020, 3:45am UTC](https://root-forum.cern.ch/t/bugs-in-tfile-when-using-c-17/40168 "2020-07-01T03:45:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ed20](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/f04885/32.png) [@ed20](https://root-forum.cern.ch/u/ed20)\
**Post date:** [July 1, 2020, 3:45am UTC](https://root-forum.cern.ch/t/bugs-in-tfile-when-using-c-17/40168/1 "2020-07-01T03:45:12Z")

</div>

Sorry if this question is too basic; I am very new to ROOT. I am trying to compile a program using some ROOT header files and the following Makefile options:

```auto
CXX = g++
CXXFLAGS = -march=native `root-config --cflags --libs` -std=c++17 
LDFLAGS = `root-config --cflags --libs`

```

The result is a huge number of errors starting with the following (when using “TString.h”)

```auto
/usr/local/bin/root_v6.20.02/include/ROOT/RStringView.hxx:32:84: error: conflicting declaration of template ‘template<class _CharT, class _Traits> using basic_string_view = std::experimental::__ROOT::basic_string_view<_CharT, _Traits>’

```

and then the second error:

```auto
In file included from /usr/include/c++/7/memory:74:0,                                                             
                 from /usr/local/bin/root_v6.20.02/include/ROOT/TypeTraits.hxx:15,                                
                 from /usr/local/bin/root_v6.20.02/include/TString.h:29,                                          
                 from /usr/local/bin/root_v6.20.02/include/TNamed.h:26,                                           
                 from /usr/local/bin/root_v6.20.02/include/TDictionary.h:44,                                      
                 from /usr/local/bin/root_v6.20.02/include/TDataType.h:25,                                        
                 from /usr/local/bin/root_v6.20.02/include/TBuffer.h:24,                                          
                 from /usr/local/bin/root_v6.20.02/include/TDirectory.h:24,                                       
                 from /usr/local/bin/root_v6.20.02/include/TDirectoryFile.h:25,                                   
                 from /usr/local/bin/root_v6.20.02/include/TFile.h:27,                                            
                 from test.cpp:2:                                                                                 
/usr/include/c++/7/ext/concurrence.h:53:16: error: ‘_Lock_policy’ does not name a type                            
   static const _Lock_policy __default_lock_policy =                                                              
                ^ ~~~~~~~~~~~                                                                                      
In file included from /usr/include/c++/7/iostream:38:0,                                                           
                 from test.cpp:1:                                                                                 
/usr/include/c++/7/ext/concurrence.h: In function ‘void std::__throw_concurrence_lock_error()’:                   
/usr/include/c++/7/ext/concurrence.h:102:5: error: ‘__concurrence_lock_error’ was not declared in this scope      
   { _GLIBCXX_THROW_OR_ABORT(__concurrence_lock_error()); }

```

I can get around this by not using TStrings directly in my code, but it seems that also the “TFile.h” header loads “TString.h” so the same problems arise. Is there an additional flag I can enable during compilation to avoid these conflicts? Or is it best to simply avoid the use of C++17 with ROOT?

* * *

_Note:_ the above errors are not due to a fault in my code, they appear even when trying to compile a 3-line “Hello world” program

_ROOT Version:_ 6.20/02  
_Platform:_ Linux (Ubuntu 18.04)  
_Compiler:_ g++ version 7.5.0

* * *

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [July 1, 2020, 7:08am UTC](https://root-forum.cern.ch/t/bugs-in-tfile-when-using-c-17/40168/2 "2020-07-01T07:08:10Z")

</div>

Hello and welcome to the ROOT forum!

The C++ compiler and standard for your program would need match the C++ standard with which ROOT has been compiled. You can check ROOT’s settings with `root-config --cflags`. If you compile ROOT yourself, you can enforce C++17 with the cmake option `CMAKE_CXX_STANDARD 17`.

As a side note, the `CXXFLAGS` variable would ideally only use `root-config --cflags` (without `libs`) and the `LDFLAGS` would use `root-config --libs`.

Cheers,  
Jakob

---

<div class="post-metadata">

**Author:** ![ed20](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/f04885/32.png) [@ed20](https://root-forum.cern.ch/u/ed20)\
**Post date:** [July 1, 2020, 5:41pm UTC](https://root-forum.cern.ch/t/bugs-in-tfile-when-using-c-17/40168/3 "2020-07-01T17:41:03Z")

</div>

thanks very much!
