-
Notifications
You must be signed in to change notification settings - Fork 865
Fix modern MSVC compilation error on experimental/filesystem #8469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,13 +36,27 @@ | |
| #include <atlfile.h> | ||
| #include <d3dcompiler.h> | ||
| #pragma comment(lib, "d3dcompiler.lib") | ||
| #if _MSC_VER >= 1920 | ||
| #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING | ||
| #include <experimental/filesystem> | ||
| #else | ||
| #include <filesystem> | ||
| #endif | ||
|
|
||
| #if defined(_MSC_VER) | ||
| // MSVC removed <experimental/filesystem> starting in VS 2019 16.3 (_MSC_VER >= 1922) | ||
| #if _MSC_VER < 1922 | ||
| #include <experimental/filesystem> | ||
| namespace fs = std::experimental::filesystem; | ||
| #else | ||
| #include <filesystem> | ||
| namespace fs = std::filesystem; | ||
| #endif | ||
| #elif defined(__has_include) && __has_include(<filesystem>) && \ | ||
| (defined(__clang__) || !defined(__GNUC__) || __GNUC__ >= 8) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to check
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As for GNUC >= 8: GCC 7 ships but doesn't actually define std::filesystem. Header exists, namespace doesn't -> compile error. GCC 8 is the first version where it really works. |
||
| #include <filesystem> | ||
| namespace fs = std::filesystem; | ||
| #else | ||
| #include <experimental/filesystem> | ||
| namespace fs = std::experimental::filesystem; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure which compiler this else case covers?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consulted an AI, and basically it looks like really old compilers would be covered by this case: are some examples.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we even support compilers that old for building dxc? LLVM has a cut off. Not sure if DXC ever required a minimum compiler version.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GCC 8 came out in 2018, and I don't think we should support compilers older than that. I think you can remove the |
||
| #endif | ||
|
|
||
| using namespace fs; | ||
|
|
||
| #include "llvm/Support/Format.h" | ||
| #include "llvm/Support/raw_ostream.h" | ||
|
|
@@ -72,8 +86,6 @@ using namespace std; | |
| using namespace hlsl_test; | ||
| #ifdef _WIN32 | ||
|
|
||
| using namespace std::experimental::filesystem; | ||
|
|
||
| static uint8_t MaskCount(uint8_t V) { | ||
| DXASSERT_NOMSG(0 <= V && V <= 0xF); | ||
| static const uint8_t Count[16] = {0, 1, 1, 2, 1, 2, 2, 3, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
experimental::filesystemwas enabled since version 1920, so it needs to be included in the check.