Rootcling with std::filesystem

Hi all,

I fail to use cling to compile a shared lib which uses std::filesystem. I have read some issues but I do not know if this has been fixed or there is any simple solution. To be specific,

// test.hh
#ifndef test_hh
#define test_hh
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;

class test
{
public:
    test();
    ~test();

private:
    fs::path path;
};

#endif

//test.cpp
#include "test.hh"
test::test()
{
    std::cout << "test constructor" << std::endl;
    this->path = ".";
}

test::~test()
{
    std::cout << "test destructor" << std::endl;
}

// compile error
root
.L test.cpp

Thanks a lot for your help.

ROOT Version: 6.28.0 (built from conda)


I tried your example. I did not get any error.

Hi,

I apologize. I made a typo. It causes an error when .L test.cpp+ but is ok without +. The error message is error: '_List' is a private member of 'std::filesystem::path'. I happen to get the same error when building with a LinkDef.h using cmake. Can you tell me what went wrong?

For me, it is working with + too:

couet@macbookcouet Downloads % root   
   ------------------------------------------------------------------
  | Welcome to ROOT 6.29/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Jun 20 2023, 09:29:44                      |
  | From heads/col-is-def@v6-29-01-1648-ge566d2865f                  |
  | With Apple clang version 12.0.5 (clang-1205.0.22.9)              |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] .L test.cpp+
Info in <TMacOSXSystem::ACLiC>: creating shared library /Users/couet/Library/Mobile Documents/com~apple~CloudDocs/Downloads/./test_cpp.so
root [1] 

I see. I guess this is fine in the latest version. Thanks !

Hello,

I confirm I am also affected by this in 6.28/04 (latest stable release). Running the example code provided at the top of this discussion, I get:

$ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/04                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on May 16 2023, 14:45:00                 |
  | From tags/v6-28-04@v6-28-04                                      |
  | With c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] .L test.cpp+
Info in <TUnixSystem::ACLiC>: creating shared library /data/giraudpf/tmp/./test_cpp.so
input_line_11:6:22: error: '_List' is a private member of 'std::filesystem::path'
   filesystem::path::_List::_Impl_deleter _1;
                     ^
/usr/include/c++/9/bits/fs_path.h:558:12: note: declared private here
    struct _List
           ^
input_line_11:7:22: error: '_List' is a private member of 'std::filesystem::path'
   filesystem::path::_List::_Impl* _0;
                     ^
/usr/include/c++/9/bits/fs_path.h:558:12: note: declared private here
    struct _List
           ^
Error in <Load>: Could not declare TEmulatedTuple<filesystem::path::_List::_Impl*,filesystem::path::_List::_Impl_deleter>
root [1] 

Should I wait for another stable release before using std::filesystem::path?

Many thanks,
Pierre-Fran├žois

Hello,
I see this issue is still there with the newly released 6.28.06:

$ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/06                        https://root.cern |
  | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Aug 30 2023, 16:45:00                 |
  | From tags/v6-28-06@v6-28-06                                      |
  | With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0                   |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] .L test.cpp+
Info in <TUnixSystem::ACLiC>: creating shared library /data/giraudpf/tmp/./test_cpp.so
input_line_11:6:22: error: '_List' is a private member of 'std::filesystem::path'
   filesystem::path::_List::_Impl_deleter _1;
                     ^
/usr/include/c++/11/bits/fs_path.h:636:12: note: declared private here
    struct _List
           ^
input_line_11:7:22: error: '_List' is a private member of 'std::filesystem::path'
   filesystem::path::_List::_Impl* _0;
                     ^
/usr/include/c++/11/bits/fs_path.h:636:12: note: declared private here
    struct _List
           ^
Error in <Load>: Could not declare TEmulatedTuple<filesystem::path::_List::_Impl*,filesystem::path::_List::_Impl_deleter>

Cheers,
Pierre-Fran├žois