Opened 6 years ago
Closed 6 years ago
#12179 closed Bugs (fixed)
Including boost/optional/optional_fwd.hpp without first including boost/config.hpp doesn't compile.
Reported by: | Owned by: | Fernando Cacciola | |
---|---|---|---|
Milestone: | Boost 1.62.0 | Component: | optional |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | Cc: |
Description
This code does not compile;
#include <boost/optional/optional_fwd.hpp>
int main() {
return 0;
}
It seems this is because optional_fwd.hpp tries to only depend on boost/config/suffix.hpp, but this file itself depends on other config macros that need to be included first.
I have been able to workaround this issue by including boost/config.hpp before optional_fwd.hpp
Change History (5)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
I posted a pull request with the (trivial) fix for this problem on Github: https://github.com/boostorg/optional/pull/19
comment:4 by , 6 years ago
A related ticket #12142 will be fixed in 1.62.0 release. Hopefully this one will be fixed as well.
comment:5 by , 6 years ago
Milestone: | To Be Determined → Boost 1.62.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Here's a slightly different problem, but with the same solution:
If optional/optional_fwd.hpp is included before any boost header that includes config.hpp (for example optional.hpp), there are multiple problems. Example:
The first problem is a build failure because of inconsistent defines:
Now, we have BOOST_HAS_INT128 defined, but boost::int128_type and boost::uint128_type are not. If we now try to compile something that includes type_traits/is_integral.hpp (which optional/optional.hpp indirectly does), we get to this code, which doesn't compile due to unknown types:
The second class of problems are redefinition warnings. Here's an example (there are multiple defines that get redefined):
As a conclusion, optional/optional_fwd.hpp should include config.hpp instead of config/suffix.hpp Currently, optional/optional_fwd.hpp is the only file in boost that includes config/suffix.hpp directly (not through config.hpp), so it's probably not meant to be used this way.
(context: I'm using gcc 5.3.1 on Fedora 23)