-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Description
When building the gopher-mcp library with C++17 (or higher) enabled via -DCMAKE_CXX_STANDARD=17, compilation fails due to ambiguous function calls for holds_alternative and get. This occurs because the library enables the std::variant code path (via MCP_USE_STD_OPTIONAL_VARIANT=1), but the compatibility wrappers in include/mcp/core/compat.h conflict with the standard library versions from <variant>.The errors appear in src/transport/ssl_context.cc (and potentially other files using variant types).
Environment
- OS: macOS (using AppleClang)
- C++ Standard: C++17
- CMake Version: 4.x
- Compiler: AppleClang (Xcode Command Line Tools)
Steps to Reproduce
- Configure with C++17:
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/opt/gopher-mcp \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_C_API=OFF \
-DBUILD_STATIC_LIBS=OFF \
-DCMAKE_CXX_STANDARD=17- Build:
cmake --build . -j4Error Output
/path/to/gopher-mcp/src/transport/ssl_context.cc:81:7: error: call to 'holds_alternative' is ambiguous
81 | if (holds_alternative<Error>(result)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/variant:1336:38: note: candidate function [with _Tp = mcp::Error, _Types = <std::nullptr_t, mcp::Error>]
1336 | _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept {
| ^
/path/to/gopher-mcp/include/mcp/core/compat.h:109:16: note: candidate function [with T = mcp::Error, Types = <std::nullptr_t, mcp::Error>]
109 | constexpr bool holds_alternative(const variant<Types...>& v) noexcept {
| ^(Similar errors occur for get and multiple locations in ssl_context.cc)
Metadata
Metadata
Assignees
Labels
No labels