Skip to content
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

<optional> requires -std=c++17 #479

Merged
merged 3 commits into from
Nov 4, 2016

Conversation

jagerman
Copy link
Member

@jagerman jagerman commented Nov 4, 2016

This is a sort of continuation of #476: attempting to include in C++14 fails in just the same way (under g++-7, which actually adds it) as attempting to include <experimental/optional> under C++11.

This fixes it.

It also has a commit that generalizes the C++14/17 detection macros a bit (to look for C++14 mode instead of just the specific features descr.h needs), and moves them to common.h instead of descr.h. (Neither MSVC or ICC get these turned on as current versions of both are still quite C++14-incomplete).

There are now more places than just descr.h that make use of these.
The new macro isn't quite the same: the old one only tested for a
couple features, while the new one checks for the __cplusplus version
(but doesn't even try to enable C++14 for MSVC/ICC).
g++ 7 adds <optional>, but including it in C++14 mode isn't allowed
(just as including <experimental/optional> isn't allowed in C++11 mode).
(This wasn't triggered in g++-6 because it doesn't provide <optional>
yet.)

This fixes the compilation under g++-7.
@@ -30,7 +30,7 @@
# define PYBIND11_NOINLINE __attribute__ ((noinline))
#endif

#if __cplusplus > 201103L
#if PYBIND11_CPP14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm -- that doesn't seem right. PYBIND11_CPP14 isn't defined until later below.

It obviously needs to be defined above the use for DEPRECATED.
@wjakob
Copy link
Member

wjakob commented Nov 4, 2016

Great, thank you!

@wjakob wjakob merged commit f1b44a0 into pybind:master Nov 4, 2016
@jagerman jagerman deleted the optional-requires-cpp17 branch November 6, 2016 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants