-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feature: support compilers that use std::experimental::filesystem #3840
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
Changes from all commits
505bf23
9e7d07b
ceb1fa4
2de5c5e
d2c4f56
c4e3cdf
235d88b
9dd08b3
6c63632
761717a
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 |
|---|---|---|
|
|
@@ -13,21 +13,28 @@ | |
| #include <string> | ||
|
|
||
| #ifdef __has_include | ||
| # if defined(PYBIND11_CPP17) && __has_include(<filesystem>) | ||
| # include <filesystem> | ||
| # define PYBIND11_HAS_FILESYSTEM 1 | ||
| # if defined(PYBIND11_CPP17) | ||
| # if __has_include(<filesystem>) && \ | ||
| PY_VERSION_HEX >= 0x03060000 | ||
| # include <filesystem> | ||
| # define PYBIND11_HAS_FILESYSTEM 1 | ||
| # elif __has_include(<experimental/filesystem>) | ||
| # include <experimental/filesystem> | ||
| # define PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM 1 | ||
| # endif | ||
| # endif | ||
| #endif | ||
|
|
||
| #if !defined(PYBIND11_HAS_FILESYSTEM) && !defined(PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL) | ||
| #if !defined(PYBIND11_HAS_FILESYSTEM) && !defined(PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM) \ | ||
| && !defined(PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL) | ||
| # error \ | ||
| "#include <filesystem> is not available. (Use -DPYBIND11_HAS_FILESYSTEM_IS_OPTIONAL to ignore.)" | ||
| "Neither #include <filesystem> nor #include <experimental/filesystem is available. (Use -DPYBIND11_HAS_FILESYSTEM_IS_OPTIONAL to ignore.)" | ||
| #endif | ||
|
|
||
| PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) | ||
| PYBIND11_NAMESPACE_BEGIN(detail) | ||
|
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. detail namespace begins here. Can you not just move the include logic after line 38?
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. If not, it's fine as is.
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 even need the namespace btw? It's only used on the type caster right? Just mimic what we do for experimental optional and spell it out twice with an IFDEF?
Contributor
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. Addressed in the latest commit. Since we're here though, what is the point of the
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. From memory: in some environments the macros insert "visibility hidden" attributes. |
||
|
|
||
| #if defined(PYBIND11_HAS_FILESYSTEM) | ||
| #if defined(PYBIND11_HAS_FILESYSTEM) || defined(PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM) | ||
| template <typename T> | ||
| struct path_caster { | ||
|
|
||
|
|
@@ -94,9 +101,16 @@ struct path_caster { | |
| PYBIND11_TYPE_CASTER(T, const_name("os.PathLike")); | ||
| }; | ||
|
|
||
| #endif // PYBIND11_HAS_FILESYSTEM || defined(PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM) | ||
|
|
||
| #if defined(PYBIND11_HAS_FILESYSTEM) | ||
| template <> | ||
| struct type_caster<std::filesystem::path> : public path_caster<std::filesystem::path> {}; | ||
| #endif // PYBIND11_HAS_FILESYSTEM | ||
| #elif defined(PYBIND11_HAS_EXPERIMENTAL_FILESYSTEM) | ||
| template <> | ||
| struct type_caster<std::experimental::filesystem::path> | ||
| : public path_caster<std::experimental::filesystem::path> {}; | ||
| #endif | ||
|
|
||
| PYBIND11_NAMESPACE_END(detail) | ||
| PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) | ||
Uh oh!
There was an error while loading. Please reload this page.