Skip to content

Compilation error on macOSX v10.13.6 #10

@olegded

Description

@olegded

Describe the bug

There is a problem in vsg::ref_ptr< vsg::Object > AsciiInput::read() when compiling on macOS v10.13.6 using clang Apple LLVM version 10.0.0 (clang-1000.11.45.5):

/Users/.../dev/osg-vulkan/vsg/src/src/vsg/io/AsciiInput.cpp:132:30: error: call to unavailable member function 'value': introduced in macOS 10.14
        ObjectID id = result.value();
                      ~~~~~~~^~~~~
In file included from /Users/.../dev/osg-vulkan/vsg/src/src/vsg/io/AsciiInput.cpp:13:
In file included from /Users/.../dev/osg-vulkan/vsg/src/include/vsg/io/AsciiInput.h:21:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/optional:942:27: note: candidate function has been explicitly made unavailable
    constexpr value_type& value() &
                          ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/optional:933:33: note: candidate function has been explicitly made unavailable
    constexpr value_type const& value() const&
                                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/optional:951:28: note: candidate function not viable: no known conversion from 'optional<...>' to 'optional<...>' for object argument
    constexpr value_type&& value() &&
                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/optional:960:34: note: candidate function not viable: no known conversion from 'optional<...>' to 'const optional<...>' for object argument
    constexpr value_type const&& value() const&&
                                 ^
1 error generated.

The definition is:

_LIBCPP_INLINE_VISIBILITY
_LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
constexpr value_type const& value() const&
{
    if (!this->has_value())
        __throw_bad_optional_access();
    return this->__get();
}

Please see this Stackoverflow thread as well. It looks like that the corresponding method is only defined in standard library shipped with macOSX v10.14 and higher, at least using default clang compiler.

To Reproduce

  • Run CMake
  • Try to compile

Posible solution

  1. Require macOSX v10.14 and higher in docs/CMake
  2. Use std::optional::operator*
ObjectID id = *result;

which seems to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions