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

v0.3.0 build error: reference to 'allocator' is ambiguous #185

Closed
YK-Unit opened this issue Jan 1, 2022 · 4 comments · Fixed by #187
Closed

v0.3.0 build error: reference to 'allocator' is ambiguous #185

YK-Unit opened this issue Jan 1, 2022 · 4 comments · Fixed by #187
Labels
help wanted Extra attention is needed

Comments

@YK-Unit
Copy link

YK-Unit commented Jan 1, 2022

I build v0.3.0 src code on macOS 11.6:

mkdir build
cmake -B build && make -C build

Then I get the following error:

-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- ryml: using C++ standard: C++11
-- ryml: setting C++ standard: 11
-- ryml: setting C++ standard required: ON
-- ryml: importing subproject c4core (SUBDIRECTORY)... /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core
-- c4core: using C++ standard: C++11
-- ryml: -----> target ryml PUBLIC incorporating lib c4core
-- ryml: packing the project:
-- ryml: cpack tag: v0.3.0-4-ge698213-master
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/York/Workspace/Cppspace/rapidyaml/build
Scanning dependencies of target ryml
[  4%] Building CXX object CMakeFiles/ryml.dir/src/c4/yml/common.cpp.o
[  8%] Building CXX object CMakeFiles/ryml.dir/src/c4/yml/node.cpp.o
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.cpp:1:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.hpp:9:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/tree.hpp:11:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/charconv.hpp:54:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float.hpp:18:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float_all.h:41:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/system_error:149:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/string:1691:1: error: reference to 'allocator' is ambiguous
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/__string:95:90: note: expanded from macro '_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST'
  _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, std::allocator<_CharType> const&)) \
                                                                                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:1623:28: note: candidate found by name lookup is 'std::__1::allocator'
class _LIBCPP_TEMPLATE_VIS allocator
                           ^
/Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/std/vector_fwd.hpp:16:26: note: candidate found by name lookup is 'std::allocator'
template<typename> class allocator;
                         ^
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.cpp:1:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.hpp:9:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/tree.hpp:11:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/charconv.hpp:54:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float.hpp:18:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float_all.h:41:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/system_error:149:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/string:1691:1: error: reference to 'allocator' is ambiguous
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/__string:111:112: note: expanded from macro '_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST'
  _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \
                                                                                                               ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:1623:28: note: candidate found by name lookup is 'std::__1::allocator'
class _LIBCPP_TEMPLATE_VIS allocator
                           ^
/Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/std/vector_fwd.hpp:16:26: note: candidate found by name lookup is 'std::allocator'
template<typename> class allocator;
                         ^
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.cpp:1:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.hpp:9:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/tree.hpp:11:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/charconv.hpp:54:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float.hpp:18:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float_all.h:41:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/system_error:149:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/string:1692:1: error: reference to 'allocator' is ambiguous
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/__string:95:90: note: expanded from macro '_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST'
  _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, std::allocator<_CharType> const&)) \
                                                                                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:1623:28: note: candidate found by name lookup is 'std::__1::allocator'
class _LIBCPP_TEMPLATE_VIS allocator
                           ^
/Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/std/vector_fwd.hpp:16:26: note: candidate found by name lookup is 'std::allocator'
template<typename> class allocator;
                         ^
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.cpp:1:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/node.hpp:9:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/src/c4/yml/tree.hpp:11:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/charconv.hpp:54:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float.hpp:18:
In file included from /Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/ext/fast_float_all.h:41:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/system_error:149:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/string:1692:1: error: reference to 'allocator' is ambiguous
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/__string:111:112: note: expanded from macro '_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST'
  _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, std::allocator<_CharType> const&)) \
                                                                                                               ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/memory:1623:28: note: candidate found by name lookup is 'std::__1::allocator'
class _LIBCPP_TEMPLATE_VIS allocator
                           ^
/Users/York/Workspace/Cppspace/rapidyaml/ext/c4core/src/c4/std/vector_fwd.hpp:16:26: note: candidate found by name lookup is 'std::allocator'
template<typename> class allocator;
                         ^
4 errors generated.
make[2]: *** [CMakeFiles/ryml.dir/src/c4/yml/node.cpp.o] Error 1
make[1]: *** [CMakeFiles/ryml.dir/all] Error 2
make: *** [all] Error 2
@biojppm
Copy link
Owner

biojppm commented Jan 1, 2022

Thanks for reporting. ryml is tested successfully in macOS 11.6.2 with XCode 13.0.0. I'll setup a workflow to try to reproduce with XCode 12.0.

biojppm added a commit that referenced this issue Jan 1, 2022
@biojppm
Copy link
Owner

biojppm commented Jan 2, 2022

Yes, the CI now shows this error as well (eg, this). Since I have no access to mac or xcode other than through the github workflows, and I cannot find what is the macro to test the xcode version, I'm going to require your help to fix this.

The problem is in the header c4/std/vector_fwd.hpp. It seems that xcode 13 needs something like:

namespace std {
template<typename> class allocator;
inline namespace __1 {
template<typename T, typename Alloc> class vector;
} // namespace __1

where as for xcode 12 std::allocator is defined inside the __1 namespace:

namespace std {
inline namespace __1 {
template<typename> class allocator;
template<typename T, typename Alloc> class vector;
} // namespace __1

That is, the fixed header is going to be something like

#if defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_MSC_VER)
....
#elif defined(_LIBCPP_VERSION) || defined(__APPLE_CC__)
#if defined(__EMSCRIPTEN__)
namespace std {
template<typename> class allocator;
inline namespace __2 {
template<typename T, typename Alloc> class vector;
} // namespace __2
} // namespace std
#else
#if (xcode_version is >= 13) // <<<<<<<<< what is the macro for this???
namespace std {
template<typename> class allocator;
inline namespace __1 {
template<typename T, typename Alloc> class vector;
} // namespace __1
} // namespace std
#else
namespace std {
inline namespace __1 {
template<typename> class allocator;
template<typename T, typename Alloc> class vector;
} // namespace __1
} // namespace std
#endif
#else
#error "unknown standard library"
#endif

So

  • first, can you confirm that moving the declaration of allocator to inside the __1 namespace fixes the compilation error?
  • second, what is the version macro that we can use to detect which xcode version is in use?

@biojppm biojppm added the help wanted Extra attention is needed label Jan 2, 2022
@biojppm
Copy link
Owner

biojppm commented Jan 2, 2022

I cannot find any reference to a macro to test the xcode version. It may be the case that _LIBCPP_VERSION is the proper macro to test.

@YK-Unit
Copy link
Author

YK-Unit commented Jan 2, 2022

My Development Env:

  • macOS Big Sur v11.6
  • Xcode v12.5.1 (12E507)
  • CLion 2021.1.3

Yes, the CI now shows this error as well (eg, this). Since I have no access to mac or xcode other than through the github workflows, and I cannot find what is the macro to test the xcode version, I'm going to require your help to fix this.

The problem is in the header c4/std/vector_fwd.hpp. It seems that xcode 13 needs something like:

namespace std {
template<typename> class allocator;
inline namespace __1 {
template<typename T, typename Alloc> class vector;
} // namespace __1

where as for xcode 12 std::allocator is defined inside the __1 namespace:

namespace std {
inline namespace __1 {
template<typename> class allocator;
template<typename T, typename Alloc> class vector;
} // namespace __1

That is, the fixed header is going to be something like

#if defined(__GLIBCXX__) || defined(__GLIBCPP__) || defined(_MSC_VER)
....
#elif defined(_LIBCPP_VERSION) || defined(__APPLE_CC__)
#if defined(__EMSCRIPTEN__)
namespace std {
template<typename> class allocator;
inline namespace __2 {
template<typename T, typename Alloc> class vector;
} // namespace __2
} // namespace std
#else
#if (xcode_version is >= 13) // <<<<<<<<< what is the macro for this???
namespace std {
template<typename> class allocator;
inline namespace __1 {
template<typename T, typename Alloc> class vector;
} // namespace __1
} // namespace std
#else
namespace std {
inline namespace __1 {
template<typename> class allocator;
template<typename T, typename Alloc> class vector;
} // namespace __1
} // namespace std
#endif
#else
#error "unknown standard library"
#endif

So

  • first, can you confirm that moving the declaration of allocator to inside the __1 namespace fixes the compilation error?
  • second, what is the version macro that we can use to detect which xcode version is in use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants