C++17 cannot include <filesystem>

Answered

I'm using latest CLion version with LLVM on OSX. I'm trying to play with new features of C++17 and one of the features I see is filesystem header file.

 

I'm trying to include it like this 

 


#include<filesystem>

namespace std = std::filesystem;

 

But the compiler is complaining the "file is not found". In my CMakeLists.txt I have :

 

cmake_minimum_required(VERSION 3.9)
project(testrunner)

set(CMAKE_CXX_STANDARD 17)

add_executable(testrunner main.cpp)

And I did select C++17 project on the begging. What am I doing wrong? Is there any special flag or option to enable the syntax highlighting and compilation?

 

Thank you for your help.

2
2 comments

@Psam Dev for gcc this works in the following way for now:

#include<experimental/filesystem>

It looks like for clang it hasn't been supported yet: https://libcxx.llvm.org/cxx1z_status.html

1
Avatar
Permanently deleted user

Thanks, works. To be sure others don't struggle with the same triviality I did: mind in uses within code itself, subsequently must also use "experimental::filesystem::" instead of "filesystem::" ;-)

1

Please sign in to leave a comment.