You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm trying to create modules based on the example file 04_simple_module. I need to use C++
I added a .hhp file in the project, which is the following:
#pragma once
#include"flecs.h"extern"C" {
typedeffloat PositionX;
typedeffloat PositionY;
voidMoveX(ecs_rows_t *rows) {
staticdouble phase = 0;
staticint offset = 0;
ECS_COLUMN(rows, PositionX, p, 1);
phase += 10 * rows->delta_time;
for (int i = 0; i < rows->count; i++) {
p[i] = sin(phase) * 100 + offset++;
}
}
voidMoveY(ecs_rows_t *rows) {
staticdouble phase = 0;
staticint offset = 0;
ECS_COLUMN(rows, PositionY, p, 1);
phase += 10 * rows->delta_time;
for (int i = 0; i < rows->count; i++) {
p[i] = cos(phase) * 100 + offset++;
}
}
/* This type is used to store handles to everything that the module contains. * When the module is loaded, this type will be registered as component, and * added to the singleton entity so applications can access module handles from * anywhere. */typedefstructMoveModule {
ECS_DECLARE_COMPONENT(PositionX);
ECS_DECLARE_COMPONENT(PositionY);
ECS_DECLARE_ENTITY(MoveX);
ECS_DECLARE_ENTITY(MoveY);
} MoveModule;
/* This macro is used to declare variables that contain the handles inside the * module. It is invoked by the ECS_IMPORT macro to declare variables in the * scope where the macro is invoked so the contents of the module can be used * after the ECS_IMPORT macro. */
#defineMoveModuleImportHandles(handles)\
ECS_IMPORT_COMPONENT(handles, PositionX);\
ECS_IMPORT_COMPONENT(handles, PositionY);\
ECS_IMPORT_ENTITY(handles, MoveX);\
ECS_IMPORT_ENTITY(handles, MoveY);\
voidMoveModuleImport(
ecs_world_t *world,
int flags)
{
/* Define module */ECS_MODULE(world, MoveModule); // THIS LINE HAS THE ERROR/* Register components */ECS_COMPONENT(world, PositionX);
ECS_COMPONENT(world, PositionY);
/* Define a system called Move that is executed every frame, and subscribes * for the 'Position' and 'Velocity' components */ECS_SYSTEM(world, MoveX, EcsOnUpdate, PositionX);
ECS_SYSTEM(world, MoveY, EcsOnUpdate, PositionY);
/* Export handles to module contents */ECS_SET_COMPONENT(PositionX);
ECS_SET_COMPONENT(PositionY);
ECS_SET_ENTITY(MoveX);
ECS_SET_ENTITY(MoveY);
}
}
But I have this error in the build:
End of search list.
In file included from /Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/src/main.cpp:5:
/Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/src/MoveModule.hpp:54:9: error: taking the address of a temporary object of type'MoveModule' [-Waddress-of-temporary]
ECS_MODULE(world, MoveModule);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/include/flecs.h:2213:5: note: expanded from macro 'ECS_MODULE'
ecs_set_singleton(world, id, {0});\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/include/flecs.h:1144:77: note: expanded from macro 'ecs_set_singleton'
_ecs_set_singleton_ptr(world, ecs_entity(component), sizeof(component), &(component)__VA_ARGS__)
^~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/src/main.cpp:5:
/Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/src/MoveModule.hpp:54:9: error: cannot initialize a variable of type'MoveModule *' with an rvalue of type'void *'
ECS_MODULE(world, MoveModule);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/pabloweremczuk/Documents/Proyectos/cpp/SFMLFlecs/include/flecs.h:2214:9: note: expanded from macro 'ECS_MODULE'
id *handles = ecs_get_singleton_ptr(world, id);\
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
To Reproduce
Create a program.
Create a module.
Try to include the module in the world.
Expected behavior
Handle the systems in the module as a unit.
Additional context
I'm trying to do it in C++, since I'm trying the framework SFML that is in C++. I'm using MacOS X Catalina.
It works well on C99.
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm trying to create modules based on the example file 04_simple_module. I need to use C++
I added a .hhp file in the project, which is the following:
But I have this error in the build:
To Reproduce
Expected behavior
Handle the systems in the module as a unit.
Additional context
I'm trying to do it in C++, since I'm trying the framework SFML that is in C++. I'm using MacOS X Catalina.
It works well on C99.
The text was updated successfully, but these errors were encountered: