问题
There have been several questions about getting experimental/filesystem to compile in the latest versions of GCC and Clang: experimental::filesystem linker error
But now filesystem has been accepted into c++17 so no more need for experimental
or the -lstdc++fs
flag, right?
Wrong I cannot even #include <filesystem>
on the head version of either clang++
or g++
when I try on: http://melpon.org/wandbox
Is there still some other argument I need? -lstdc++fs
just gives me the experimental
version, how can I include the officially accepted version?
回答1:
It is not specified in the C++ standards how exactly you must invoke your compiler. I guess this is up to implementations to decide, so there might still be a need for -lstdc++fs
.
Note that C++17 is not yet officially a standard, and implementations may or may not yet have implemented it. Even when C++17 finally becomes a standard, this won't magically change the implementation. It doesn't even define what linker flags an implementation should or should not require. It is completely unrelated.
How you can include the officially accepted version after C++17 becomes a standard and your implementation begins to support it, is completely implementation-specific. We'll probably just have to wait and see how that works out.
来源:https://stackoverflow.com/questions/42129775/why-must-i-still-use-lstdcfs