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

EnTT really work on windows ? #96

Closed
Milerius opened this issue Jun 8, 2018 · 14 comments · Fixed by #531
Closed

EnTT really work on windows ? #96

Milerius opened this issue Jun 8, 2018 · 14 comments · Fixed by #531
Assignees
Labels
invalid not a bug/not an issue/not whatever you want

Comments

@Milerius
Copy link
Contributor

Milerius commented Jun 8, 2018

Hey using vcpkg + entt 2.6.1

  entity_registry_.each([this](auto entity) {
                this->entity_registry_.destroy(entity);
            });

this snippet doesn't compile with the following error
ecs-test.cpp

c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(567): warning C4003: not enough actual parameters for macro 'min' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(625): warning C4003: not enough actual parameters for macro 'min' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(633): warning C4003: not enough actual parameters for macro 'max' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(756): warning C4003: not enough actual parameters for macro 'min' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(552): error C2589: '(': illegal token on right side of '::' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(901): note: see reference to class template instantiation 'entt::View<Entity,Component...>' being compiled
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(567): error C2589: '(': illegal token on right side of '::' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(625): error C2589: '(': illegal token on right side of '::' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(633): error C2589: '(': illegal token on right side of '::' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(756): error C2589: '(': illegal token on right side of '::' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]

@skypjack skypjack self-assigned this Jun 8, 2018
@skypjack skypjack added the invalid not a bug/not an issue/not whatever you want label Jun 8, 2018
@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

Fortunately yes, or at least appveyor says so.
If you can provide a minimal example to reproduce the error and all the details of your toolchain, we can try to solve the problem.
Otherwise I must tag the issue as invalid and close it. I'm sorry.

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

for my ci -> https://ci.appveyor.com/project/Milerius/shiva

cmake part of entt:

include(CMakeSources.cmake)
set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})


find_path(ENTT_INCLUDE_DIR entt/entt.hpp)
MSG_YELLOW_BOLD(STATUS "ENTT_INCLUDE_DIR: " "${ENTT_INCLUDE_DIR}" "")

CREATE_MODULE(shiva::entt "${MODULE_SOURCES}" ${MODULE_PATH})
target_include_directories(shiva-entt INTERFACE ${ENTT_INCLUDE_DIR})
namespace shiva::error
{
    class general_handler
    {
    public:
        void receive(const shiva::event::fatal_error_occured &evt)
        {
            entity_registry_.each([this](auto entity) {
                this->entity_registry_.destroy(entity);
            }); // doesn't compile on windows
            dispatcher_.trigger<shiva::event::quit_game>(evt.ec_.value());
        }

        general_handler(entt::dispatcher &dispatcher, entt::entity_registry &entity_registry) noexcept :
            dispatcher_(dispatcher),
            entity_registry_(entity_registry)
        {
            this->dispatcher_.sink<shiva::event::fatal_error_occured>().connect(this);
            if (shiva::fs::exists("stacktrace/backtrace.dump")) {
                // there is a backtrace
                std::ifstream ifs("stacktrace/backtrace.dump");

                shiva::bs::stacktrace st = shiva::bs::stacktrace::from_dump(ifs);
                std::cerr << "Previous run crashed:\n" << st << std::endl;

                // cleaning up
                ifs.close();
                shiva::fs::remove("stacktrace/backtrace.dump");
            }
        }

    private:
        entt::dispatcher &dispatcher_;
        entt::entity_registry &entity_registry_;
    };

as you can see it's compile on Linux on my ci, but not on windows :/

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

I found the problem I'm compiling with flags / permissive- https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance
on windows, it's a very important flag. (It seems that EnTT does not compile with / permissive- we could look at this. problem together if you want and try to solve it via another issue?

permissive-:
Use this option to help you identify and fix conformance issues in your code, to make it both more correct and more portable.)

my program now compiles without /permissive-

@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

So, Windows has a flag that makes our code more portable by rejecting valid code? :-D
Love it, really.

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

i dont know but may be we can look together if you want, or report an error to MSVC team

@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

I was already looking at the error, but I don't know how to solve it.
It looks like it considers malformed expressions like this one:

return std::min({ pool<Component>().size()... });

Not sure about a workaround that doesn't affect everything.
Any idea?

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

If i reminder, std::min on windows is a macro, may be it's the problem, we can try to do our own min function and try with /permissive- to compile entt

i will ask in #msvc channel in cpplang.sh slack

@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

A macro? Why that? The language is mandatory about std::min, it's defined as a function template.
I've used std::min all around in the codebase, this will break things a bit actually.

Btw, if it's a macro, why it doesn't complain without permissive flag?

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

It's does with /W4 msvc flags
c:\tools\vcpkg\installed\x64-windows\include\entt\entity\view.hpp(567): warning C4003: not enough actual parameters for macro 'min' [C:\projects\shiva\build\tests\ecs-test\ecs-test.vcxproj]

Combined with /permissive- it's turn this warning into an illegal error

I think the solution it's to use own min function for windows, since they didn't plan to remove this macro i think

@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

It seems you can solve the problem your side by defining a macro that disable those macros (it makes me cry).
Probably, if it solves, it's worth adding the macro in the configuration file for EnTT.
Can you try it?

@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

This:

#ifndef NOMINMAX
#define NOMINMAX
#endif

Should be put before any other include.
I don't think it will work as expected if set by the configuration file of EnTT.

If it solves your problem, well, it would confirm that it's in charge to users to turn off such annoying macros on Windows.

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

i will put in my cmake a compile definition that define NOMINMAX, ty

(use boost/stacktrace.hpp in my project that include windows.h) and windows.h have a macro min/max... sorry

@skypjack
Copy link
Owner

skypjack commented Jun 8, 2018

Don't worry, it's not a problem of my fault or your fault.
I want to help you to solve your issue somehow. ;-)

@Milerius
Copy link
Contributor Author

Milerius commented Jun 8, 2018

thanks ! i close the issue !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid not a bug/not an issue/not whatever you want
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants