Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Build fails on MacOS with "reference to 'string_view' is ambiguous" #390

@cajun-rat

Description

@cajun-rat

Since commit #0dda8cc61dd483535d2b8eb1548b87765d977436 the cquery build fails on Mac with the following error:

[ 5/77] Compiling src/clang_translation_unit.cc
In file included from ../../src/clang_translation_unit.cc:1:
In file included from ../../src/clang_translation_unit.h:3:
In file included from ../../src/clang_cursor.h:3:
In file included from ../../src/position.h:7:
../../src/serializer.h:349:60: error: reference to 'string_view' is ambiguous
void ReflectMember(Reader& visitor, const char* name, std::string_view& view);
                                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:736:37: note: candidate found by name lookup is 'std::__1::string_view'
typedef basic_string_view<char>     string_view;
                                    ^
../../third_party/string_view.hpp:48:38: note: candidate found by name lookup is 'std::string_view'
            using std::experimental::string_view;
                                     ^
In file included from ../../src/clang_translation_unit.cc:1:
In file included from ../../src/clang_translation_unit.h:3:
In file included from ../../src/clang_cursor.h:3:
In file included from ../../src/position.h:7:
../../src/serializer.h:350:60: error: reference to 'string_view' is ambiguous
void ReflectMember(Writer& visitor, const char* name, std::string_view& view);
                                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:736:37: note: candidate found by name lookup is 'std::__1::string_view'
typedef basic_string_view<char>     string_view;
                                    ^
../../third_party/string_view.hpp:48:38: note: candidate found by name lookup is 'std::string_view'
            using std::experimental::string_view;
                                     ^
2 errors generated.

I'm guessing this is a conflict between the polyfill that is shipped in third_party and whatever xcode is shipping.

I managed to make the build pass by hacking string_view.hpp to always include the platform string_view:

diff --git a/third_party/string_view.h b/third_party/string_view.h
index e0067ba..22b1168 100644
--- a/third_party/string_view.h
+++ b/third_party/string_view.h
@@ -1,6 +1,5 @@
 #if __cplusplus < 201703L
-#define STX_NAMESPACE_NAME std
-#include "string_view.hpp"
+#include <string_view>
 #else
 #include <string_view>
 #endif

This is clearly not a real solution, but does suggest that the problem is related to autodetection of when the polyfill is needed. I'm not sure what the best solution for this is though

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