Clangd can't find std::filesystem

So, I want to use the std::filesystem namespace in my project and discovered that clangd didn’t find it.

So, I checked whether I made a typo. Nope. However, clangd did find the needed header. After that I checked the header in question. Everything seemed in order. the namespace std was there, and so was filesystem.

After checking the sources, I went looking at the configuration of clangd and thought I needed to inform clangd about the standard being used, so I went to my .clangd and added it, to no avail. Clangd keeps complaining and here’s my .clangd file:
CompileFlags:
Add: -I/usr/include/fltk/
Add: -std=C++17

I’m actually stumped. How can I get clangd to recognize the std::filesystem namespace?

Thanks for the help.

1 Like

A good thing to check in a case like this is clangd’s logs (accessible .e.g in vscode via the “clangd” option in the Output window). The log shows what compile command clangd is actually using to process the file, so you can see if the expected flags are there.

1 Like

What’s the exact error you’re getting? How are you compiling your project? Are you using Cmake or just compile flags?

There is an error in the flags you have provided, -std=C++17 should be -std=c++17. Not sure if you put the capital C there when writing here or not.

I am able to include and use std::filesystem with clangd.

@bliep Of course many thing will comes after handwork so i thinks this problem will solve after many failures. :slightly_smiling_face: