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

Build fails with Clang5.0 (C ++ 17) #87

Closed
ghost opened this issue Mar 7, 2020 · 8 comments
Closed

Build fails with Clang5.0 (C ++ 17) #87

ghost opened this issue Mar 7, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Mar 7, 2020

Build error occurs in VisualStdio Android development environment.
The build is RMLUI_STATIC_LIB only
gnustl_static

Code I tentatively addressed

./Include/RmlUi/Core/Types.h
template <class T> struct hash { using utype = typename ::std::underlying_type<T>::type; size_t operator() (const T& t) const { ::std::hash<utype> h; return h(static_cast<utype>(t)); }

to

``
#ifdef ANDROID

template <> struct hash<::Rml::Core::PropertyId> {
using utype = typename ::std::underlying_type<::Rml::Core::PropertyId>::type;
size_t operator() (const ::Rml::Core::PropertyId& t) const { ::std::hash h; return h(static_cast(t)); }
#endif
``

@ghost
Copy link
Author

ghost commented Mar 7, 2020

a909b18

errors

Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1344
Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1339
Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1269
Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1922
Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1269
Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1964
Error call to non-static member function without an object argument Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 2021
Error cannot initialize object parameter of type 'const std::equal_toRml::Core::Character' with an expression of type 'const robin_hood::detail::Table<true, 80, Rml::Core::Character, Rml::Core::FontGlyph, robin_hood::hashRml::Core::Character, std::equal_toRml::Core::Character >' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1339
Error cannot initialize object parameter of type 'const std::equal_toRml::Core::Character' with an expression of type 'const robin_hood::detail::Table<true, 80, Rml::Core::Character, Rml::Core::FontGlyph, robin_hood::hashRml::Core::Character, std::equal_toRml::Core::Character >' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1344
Error implicit instantiation of undefined template 'std::hashRml::Core::Character' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 747
Error implicit instantiation of undefined template 'std::hashRml::Core::Character' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 747
Error implicit instantiation of undefined template 'std::hashRml::Core::Character' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 747
Error implicit instantiation of undefined template 'std::hashRml::Core::Character' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 747
Error implicit instantiation of undefined template 'std::hashRml::Core::Character' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 747
Error no matching member function for call to 'keyToIdx' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1958
Error no matching member function for call to 'keyToIdx' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 2016
Error no member named 'align' in namespace 'std' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Source\Core\Memory.h 66
Error no member named 'align' in namespace 'std' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Source\Core\Memory.h 66
Error no member named 'operator()' in 'robin_hood::detail::WrapHash<robin_hood::hashRml::Core::Character >' Library_RmlUi (Android\01_Library\Library_RmlUi) C:\dev\c\MMDAgent-1.4\Library_RmlUi\Include\RmlUi\Core\Containers\robin_hood.h 1269

@ghost
Copy link
Author

ghost commented Mar 7, 2020

ndk is std::align not supported
https://stackoverflow.com/questions/27064791/stdalign-not-supported-by-g4-9

fix plan

./Include/RmlUi/Core/Types.h
namespace std { inline void* align(std::size_t alignment, std::size_t size, void*& ptr, std::size_t& space) { std::uintptr_t pn = reinterpret_cast<std::uintptr_t>(ptr); std::uintptr_t aligned = (pn + alignment - 1) & -alignment; std::size_t padding = aligned - pn; if (space < size + padding) return nullptr; space -= padding; return ptr = reinterpret_cast<void*>(aligned); } }

@ghost
Copy link
Author

ghost commented Mar 7, 2020

std::hash<::Rml::Core::Character> need add.

Now the build passes.

``
namespace std {
// Hash specialization for enum class types (required on some older compilers)
template <> struct hash<::Rml::Core::PropertyId> {
using utype = typename ::std::underlying_type<::Rml::Core::PropertyId>::type;
size_t operator() (const ::Rml::Core::PropertyId& t) const { ::std::hash h; return h(static_cast(t)); }
};

template <> struct hash<::Rml::Core::Character> {
using utype = typename ::std::underlying_type<::Rml::Core::Character>::type;
size_t operator() (const ::Rml::Core::Character& t) const { ::std::hash h; return h(static_cast(t)); }
};

inline void* align(std::size_t alignment, std::size_t size,
void*& ptr, std::size_t& space) {
std::uintptr_t pn = reinterpret_caststd::uintptr_t(ptr);
std::uintptr_t aligned = (pn + alignment - 1) & -alignment;
std::size_t padding = aligned - pn;
if (space < size + padding) return nullptr;
space -= padding;
return ptr = reinterpret_cast<void*>(aligned);
}
}
``

@viciious
Copy link
Contributor

viciious commented Mar 7, 2020

Isn't gnustl_static deprecated in favor of c++_static?

@ghost
Copy link
Author

ghost commented Mar 7, 2020

In my project, I built using gnustl_static because c ++ _ static did not have enough functions to build.

@mikke89
Copy link
Owner

mikke89 commented Mar 7, 2020

I'm unable to test this, so please let me know if it works :)

@ghost
Copy link
Author

ghost commented Mar 8, 2020

Build was OK.
Thank you for the fix!

@mikke89
Copy link
Owner

mikke89 commented Mar 8, 2020

Great!

@mikke89 mikke89 closed this as completed Mar 8, 2020
@mikke89 mikke89 added the bug Something isn't working label Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants