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 Error C2244 when including RmlUI/Core.h #734

Open
derpeg opened this issue Mar 3, 2025 · 3 comments
Open

Build Error C2244 when including RmlUI/Core.h #734

derpeg opened this issue Mar 3, 2025 · 3 comments
Labels
build Build system and compilation support Usage questions

Comments

@derpeg
Copy link

derpeg commented Mar 3, 2025

Hi there.

I'm trying to integrate RmlUI into my toy project, but as soon as I include RmlUi/Core.h my build fails with the error below.

1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>main.cpp
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(52): error C2244: 'Rml::Variant::GetInto': unable to match function definition to an existing declaration
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(51): note: see declaration of 'Rml::Variant::GetInto'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(52): note: definition
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(52): note: 'bool Rml::Variant::GetInto(T &) const'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(52): note: existing declarations
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(52): note: 'bool Rml::Variant::GetInto(T &) const'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(52): note: 'bool Rml::Variant::GetInto(T &) const'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(88): error C2244: 'Rml::Variant::GetInto': unable to match function definition to an existing declaration
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(87): note: see declaration of 'Rml::Variant::GetInto'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(88): note: definition
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(88): note: 'bool Rml::Variant::GetInto(T &) const'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(88): note: existing declarations
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(88): note: 'bool Rml::Variant::GetInto(T &) const'
1>d:\casdev\temp\test\build2_deps\rmlui-src\include\rmlui\core\Variant.inl(88): note: 'bool Rml::Variant::GetInto(T &) const'
1>Done building project "test2.vcxproj" -- FAILED.
2>------ Skipped Build: Project: INSTALL, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 1 skipped ==========

This is VS 2017 (15.9.70). Solution was generated using CMake 3.15. I'm aware this is a little ancient, but since I'm able to build RmlUI plus samples from a standalone clone just fine I assume I'm only missing a stupid detail.

Minimal CMakeLists.txt I'm using to repro the issue:

cmake_minimum_required(VERSION 3.15)

include(FetchContent)

FetchContent_Declare(
    rmlui
    GIT_REPOSITORY https://github.com/mikke89/RmlUi.git
    GIT_TAG        6.0
    GIT_SHALLOW    TRUE
    GIT_PROGRESS   TRUE
)

set(RMLUI_BACKEND     Win32_GL2 CACHE STRING "" FORCE)
set(RMLUI_FONT_ENGINE none      CACHE STRING "" FORCE)

FetchContent_MakeAvailable(rmlui)

project(foo)

add_executable(bar)

target_sources(bar PRIVATE main.cpp)

target_link_libraries(bar
    PUBLIC
        RmlUi::RmlUi
)

main.cpp is nothing but:

#include <RmlUi/Core.h>

int main() {
    return 0;
}

Any hints?

@mikke89 mikke89 added support Usage questions build Build system and compilation labels Mar 3, 2025
@mikke89
Copy link
Owner

mikke89 commented Mar 3, 2025

Hello!

Yeah, VS 2017 is quite ancient, although we still have some minimal testing. And it's curious that the library builds fine for you, but can't be used from this project.

What you could try is to include individual headers from RmlUi, and see if that helps. What I would also test is to build with the commands printed. E.g. try with the Ninja generator and pass -v during build. Compare the RmlUi samples to your own project, and see if there are any differences to compile definitions or otherwise.

But really, I would mainly suggest to upgrade your compiler ;)

@derpeg
Copy link
Author

derpeg commented Mar 4, 2025

Thanks for your feedback!

This morning I did some more digging with a fresh mind and I think I found the issue: The declarations of GetInto(...) in Variant.h use std::enable_if_t, while the definitions in Variant.inl use std::enable_if. Bringing them in line at least fixes the compilation.

Not sure why this is causing issues as it should be equivalent, but having them different is maybe really not that clean? Since I don't feel like digging any further and can't quickly update my env (company PC ;)) I'll simply use this as a local patch for now. Let me know if you'd like a PR for it.

Cheers!

diff --git a/Include/RmlUi/Core/Variant.inl b/Include/RmlUi/Core/Variant.inl
index c5422af..a5a36ab 100644
--- a/Include/RmlUi/Core/Variant.inl
+++ b/Include/RmlUi/Core/Variant.inl
@@ -47,7 +47,7 @@ Variant& Variant::operator=(T&& t)
 	return *this;
 }
 
-template <typename T, typename std::enable_if<!std::is_enum<T>::value, int>::type>
+template <typename T, typename std::enable_if_t<!std::is_enum<T>::value, int>>
 bool Variant::GetInto(T& value) const
 {
 	switch (type)
@@ -83,7 +83,7 @@ bool Variant::GetInto(T& value) const
 	return false;
 }
 
-template <typename T, typename std::enable_if<std::is_enum<T>::value, int>::type>
+template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int>>
 bool Variant::GetInto(T& value) const
 {
 	static_assert(sizeof(T) <= sizeof(int64_t), "Enum underlying type exceeds maximum supported integer type size");

@mikke89
Copy link
Owner

mikke89 commented Apr 6, 2025

Hey, I must have missed this one earlier. I am happy to hear that you resolved the issue, a quick PR would very much be welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system and compilation support Usage questions
Projects
None yet
Development

No branches or pull requests

2 participants