Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Symbol std::filesystem could not be resolved(Problem recognizing the symbol mentioned, but code compiles and runs)
Symbol std::filesystem could not be resolved [message #1836223] Thu, 24 December 2020 17:11 Go to next message
Michele Guerra is currently offline Michele GuerraFriend
Messages: 3
Registered: December 2020
Junior Member
Hi everyone,

I have a problem when trying to use the standard library filesystem namespace, introduced with C++17.
Eclipse doesn't seem to recognize the symbol (std::filesystem is highlighted and says "symbol could not be recognized"), but I believe I updated the compiler accordingly, because the program compiles and runs, and I am able to call functions from that namespace.

I found another issue with a similar problem (https://www.eclipse.org/forums/index.php/t/285005/), but the suggestions provided didn't help me. I went to Project Properties -> C/C++ General -> Paths and Symbols -> Includes, and in include directories I added a lot of them like this: C:\MinGW\lib\gcc\mingw32\9.2.0\include\c++.

In the directory aforementioned there is a file called filesystem! What am I doing wrong? The error is very annoying.
Thanks to anybody who's willing to help!
Re: Symbol std::filesystem could not be resolved [message #1836240 is a reply to message #1836223] Fri, 25 December 2020 18:48 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Note that the include for <filesystem> isn't flagged.
The indexer was able to locate it.
The line with the namespace IS being flagged and std::filesystem is underlined.
This is probably indicating that std::filesystem doesn't exist.

It's possible that the __cpluplus macro set by the compiler builtin reporting has the wrong c++ standard.
Check that __cpluplus is greater than or equal to 201703L.
The builtin results can be viewed in the consolidated discovery dialogs
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Entries tab

If it is lower than 201703L then you have to include --std=c++17 in the builtins command.


For Paths and Symbols entries to be passed to the indexer,
you need to have the Managed Build Settings Entries enabled in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.

You shouldn't have to set the builtin includes in Paths and Symbols.

EDIT: I was saying std::filespace instead of std::filesystem. Fixed it.

[Updated on: Sat, 26 December 2020 06:49]

Report message to a moderator

Re: Symbol std::filesystem could not be resolved [message #1836244 is a reply to message #1836240] Sat, 26 December 2020 00:21 Go to previous messageGo to next message
Michele Guerra is currently offline Michele GuerraFriend
Messages: 3
Registered: December 2020
Junior Member
First of all,
thanks for your kind and quick response, it gave me nice insights on where to look if I end up with similar problems in the future.

I looked up at the Entries tab for the GCC Built-In Compiler Settings as you mentioned and you were right: i had the __cplusplus equal to 2014.

Therefore I went to:
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Providers --> GCC Built-In Compiler Settings
and here I typed ${COMMAND} ${FLAGS} -E -P -v -dD --std=c++17 "${INPUTS}" in the Command to get compiler specs.

This changed __cplusplus to 201703L as you expected, but unfortunately this fix didn't seem to solve the issue. I'm still able to run my code but the std::filesystem is not recognized.
Do you know if there's another fix that I could make to have this to work? Thank you already in advance!
Re: Symbol std::filesystem could not be resolved [message #1836249 is a reply to message #1836244] Sat, 26 December 2020 06:31 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You may need to rebuild the index (Project --> C/C++ Index --> Rebuild)
Other than that, no.

EDIT:
Actually, if rebuilding doesn't work,
you may need to track down the header to where the namespace is defined.
There may be another reason why it is being ignored.
I don't have MinGW, so I can't say for sure.

[Updated on: Sat, 26 December 2020 06:44]

Report message to a moderator

Re: Symbol std::filesystem could not be resolved [message #1836253 is a reply to message #1836249] Sat, 26 December 2020 15:06 Go to previous message
Michele Guerra is currently offline Michele GuerraFriend
Messages: 3
Registered: December 2020
Junior Member
Eureka!
Rebuilding the Index after all the operations made yesterday fixed the issue, before I only tried closing and opening the project but that didn't work.

I would never have made it without your help, thanks a lot!

[Updated on: Sat, 26 December 2020 15:11]

Report message to a moderator

Previous Topic:Fix project properties to run it.
Next Topic:How to index external folder?
Goto Forum:
  


Current Time: Sat Oct 05 08:54:10 GMT 2024

Powered by FUDForum. Page generated in 0.04526 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top