0

I'm trying to run some very simple code from the accepted answer for this question in VS Code: How can I get the list of files in a directory using C or C++?

However, VS Code keeps giving me errors with the filesystem library such as follows:

error: ‘filesystem’ is not a namespace-name
   32 | namespace fs = std::filesystem;

I can't figure out why this is happening. I checked my version of GCC and it's listed as 9.3.0. Any help would be appreciated!

Yuerno
  • 751
  • 1
  • 8
  • 27
  • 6
    Did you enable c++17? It's probably not the default. – drescherjm Feb 11 '21 at 22:20
  • I believe [https://gcc.gnu.org/projects/cxx-status.html#cxx14](https://gcc.gnu.org/projects/cxx-status.html#cxx14) says that c++14 is the default ***GCC has full support for the of the 2014 C++ standard. This mode is the default in GCC 6.1 up until GCC 10 (including);*** – drescherjm Feb 11 '21 at 22:24
  • @drescherjm Where would I enable that? In my c_cpp_properties.json file I have "cppStandard" set to gnu++17, is that correct? – Yuerno Feb 11 '21 at 22:28
  • Ah, okay. So the solution is that I need a newer version of GCC? – Yuerno Feb 11 '21 at 22:29
  • `tasks.json` and `c_cpp_properties.json`. `c_cpp_properties.json` is for intellisense while `tasks.json` is about building. – drescherjm Feb 11 '21 at 23:31
  • 1
    @drescherjm I see, thank you! I actually ended up being able to fix the issue by adding the C++ 17 standard to my cmake file, which I didn't think about until your answer, so thanks! – Yuerno Feb 12 '21 at 21:26
  • I did not know you were using CMake. – drescherjm Feb 12 '21 at 21:28

0 Answers0