Entt: <Windows.h> breaks EnTT

Created on 30 Jun 2019  路  3Comments  路  Source: skypjack/entt

I was trying to implement EnTT into my own game engine and I encountered very interesting problem. It looks like EnTT doesn't work at all with win32 window apps.

To investigate the problem I created fresh new solution with empty project in Visual Studio 2017. Then I copied all EnTT files into project and proper configuration. Then I added main class with this simple code:

#include "pch.h"
#include <entt.hpp>
#include <iostream>

int main() {
    entt::registry registry;
    std::cout << "It works!";
    return 0;
}

And it worked like a charm. In my game engine I'm using Win32 Windows API, so I need to include "Windows.h" header file. So I included it into my simple main function like this:

#include "pch.h"
#include <Windows.h>
#include <entt.hpp>
#include <iostream>

int main() {
    entt::registry registry;
    std::cout << "It works!";
    return 0;
}

And... It failed to compile due to:

1>------ Build started: Project: EnTT_test, Configuration: Debug x64 ------
1>EnTT_test.cpp
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(142): warning C4003: not enough arguments for function-like macro invocation 'min'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(204): warning C4003: not enough arguments for function-like macro invocation 'min'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(230): warning C4003: not enough arguments for function-like macro invocation 'min'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(142): error C2059: syntax error: ')'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(269): note: see reference to class template instantiation 'entt::basic_runtime_view<Entity>' being compiled
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(142): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(269): error C2143: syntax error: missing ')' before ';'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(269): error C2059: syntax error: ')'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(269): error C2238: unexpected token(s) preceding ';'
1>c:\users\jbili\source\repos\entt_test\entt\src\entity\runtime_view.hpp(269): fatal error C1201: unable to continue after syntax error in class template definition
1>Done building project "EnTT_test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

It looks like some elements (like min) are already defined in "Windows.h", so it won't compile. It's a preatty big issue in my opinion, becuase most DirectX games are using this include.

duplicate invalid

Most helpful comment

All 3 comments

you can use windows lean and mean

It fixed the problem! Thanks!

Was this page helpful?
0 / 5 - 0 ratings