entt: entt fails to compile in C++20 when used inside a module interface file
I tried to wrap some entt functionality for a project in C++20 modules, however when entt::registry is used in a module interface the compilation fails in this way:
[1/16] Scanning F:\Pawprint\source\ecs\world.cxxm for CXX dependencies
world.cxxm
[2/16] Generating CXX dyndep file CMakeFiles\Pawprint.dir\CXX.dd
[3/6] Building CXX object CMakeFiles\Pawprint.dir\source\ecs\world.cxxm.obj
FAILED: CMakeFiles/Pawprint.dir/source/ecs/world.cxxm.obj
C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\cl.exe /nologo /TP -DGRAPHICS_API_OPENGL_33 -DPLATFORM_DESKTOP -DSPDLOG_COMPILED_LIB -DTRACY_ENABLE -IF:\Pawprint\external -IF:\Pawprint\external\imgui -IF:\Pawprint\external\rlimgui -IF:\Pawprint\external\json\single_include\nlohmann -IF:\Pawprint\cmake-build-debug\_deps\raylib-src\src -IF:\Pawprint\cmake-build-debug\_deps\raylib-src\src\external\glfw\include -IF:\Pawprint\external\spdlog\include -external:IF:\Pawprint\external\tracy\public -external:W0 /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /utf-8 /showIncludes @CMakeFiles\Pawprint.dir\source\ecs\world.cxxm.obj.modmap /FoCMakeFiles\Pawprint.dir\source\ecs\world.cxxm.obj /FdCMakeFiles\Pawprint.dir\Pawprint.pdb /FS -c F:\Pawprint\source\ecs\world.cxxm
world.cxxm
F:\Pawprint\external\entt.h(1435): error C2760: syntax error: '&&' was unexpected here; expected 'expression'
F:\Pawprint\external\entt.h(1435): note: the template instantiation context (the oldest one first) is
F:\Pawprint\source\ecs\world.ixx(9): note: see reference to class template instantiation 'entt::basic_registry<entt::entity,std::allocator<entt::entity>>' being compiled
F:\Pawprint\external\entt.h(38215): note: see reference to class template instantiation 'entt::dense_map<entt::id_type,std::shared_ptr<entt::basic_sparse_set<Entity,Allocator>>,entt::identity,std::equal_to<entt::id_type>,std::allocator<std::pair<const entt::id_type,std::shared_ptr<entt::basic_sparse_set<Entity,Allocator>>>>>' being compiled
with
[
Entity=entt::entity,
Allocator=std::allocator<entt::entity>
]
F:\Pawprint\external\entt.h(4053): note: see reference to class template instantiation 'entt::compressed_pair<std::vector<size_t,std::allocator<size_t>>,entt::identity>' being compiled
F:\Pawprint\external\entt.h(1435): error C2057: expected constant expression
F:\Pawprint\external\entt.h(1435): error C2059: syntax error: '&&'
F:\Pawprint\external\entt.h(3453): error C2760: syntax error: '&&' was unexpected here; expected 'expression'
F:\Pawprint\external\entt.h(3453): error C2057: expected constant expression
F:\Pawprint\external\entt.h(3453): error C2059: syntax error: '&&'
[4/6] Building CXX object CMakeFiles\PawprintExample.dir\example\main.cpp.obj
FAILED: CMakeFiles/PawprintExample.dir/example/main.cpp.obj
C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\cl.exe /nologo /TP -DGRAPHICS_API_OPENGL_33 -DPLATFORM_DESKTOP -DSPDLOG_COMPILED_LIB -DTRACY_ENABLE -IF:\Pawprint\external -IF:\Pawprint\external\imgui -IF:\Pawprint\external\rlimgui -IF:\Pawprint\external\json\single_include\nlohmann -IF:\Pawprint -IF:\Pawprint\cmake-build-debug\_deps\raylib-src\src -IF:\Pawprint\cmake-build-debug\_deps\raylib-src\src\external\glfw\include -IF:\Pawprint\external\spdlog\include -external:IF:\Pawprint\external\tracy\public -external:W0 /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /utf-8 /showIncludes @CMakeFiles\PawprintExample.dir\example\main.cpp.obj.modmap /FoCMakeFiles\PawprintExample.dir\example\main.cpp.obj /FdCMakeFiles\PawprintExample.dir\ /FS -c F:\Pawprint\example\main.cpp
F:\Pawprint\external\entt.h(1435): error C2760: syntax error: '&&' was unexpected here; expected 'expression'
F:\Pawprint\external\entt.h(1435): note: the template instantiation context (the oldest one first) is
F:\Pawprint\source\ecs\world.ixx(9): note: see reference to class template instantiation 'entt::basic_registry<entt::entity,std::allocator<entt::entity>>' being compiled
F:\Pawprint\external\entt.h(38215): note: see reference to class template instantiation 'entt::dense_map<entt::id_type,std::shared_ptr<entt::basic_sparse_set<Entity,Allocator>>,entt::identity,std::equal_to<entt::id_type>,std::allocator<std::pair<const entt::id_type,std::shared_ptr<entt::basic_sparse_set<Entity,Allocator>>>>>' being compiled
with
[
Entity=entt::entity,
Allocator=std::allocator<entt::entity>
]
F:\Pawprint\external\entt.h(4053): note: see reference to class template instantiation 'entt::compressed_pair<std::vector<size_t,std::allocator<size_t>>,entt::identity>' being compiled
F:\Pawprint\external\entt.h(1435): error C2057: expected constant expression
F:\Pawprint\external\entt.h(1435): error C2059: syntax error: '&&'
F:\Pawprint\external\entt.h(3453): error C2760: syntax error: '&&' was unexpected here; expected 'expression'
F:\Pawprint\external\entt.h(3453): error C2057: expected constant expression
F:\Pawprint\external\entt.h(3453): error C2059: syntax error: '&&'
ninja: build stopped: subcommand failed.
This example error is produced by this code:
// world.ixx
module;
#include <entt.h>
export module world;
export class world {
public:
entt::registry r;
};
// main.cpp
import world;
int main() {
world w;
}
The code compiles perfectly fine when the exact same class is copied to a traditional C++ file, like on top of the main file as an example.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (6 by maintainers)
Commits related to this issue
- chore(ci): exclude MSVC (skypjack/entt#1216) — committed to Ryu204/stay3 by Ryu204 2 years ago
- chore(ci): exclude MSVC (github.com/skypjack/entt#1216) — committed to Ryu204/stay3 by Ryu204 2 years ago
- chore(ci): exclude MSVC because entt failed to build skypjack/entt#1216 — committed to Ryu204/stay3 by Ryu204 2 years ago
GCC doesn’t support P1815R2: Translation-unit-local entities at the moment. See more here https://gcc.gnu.org/projects/cxx-status.html.