diff --git a/examples/c/entities/fwd_declare_component/src/main.c b/examples/c/entities/fwd_declare_component/src/main.c index d060aa8775..0c12fa8a83 100644 --- a/examples/c/entities/fwd_declare_component/src/main.c +++ b/examples/c/entities/fwd_declare_component/src/main.c @@ -6,7 +6,7 @@ // component id, but this variable is scoped to the function only. When trying // to access the component from another function, this typically causes errors // that look like this: -// "FLECS__EComponentName" is undefined +// "FLECS_IDComponentNameID" is undefined // // Forward declaring a component will make the component id available from other // functions, which fixes this error. @@ -17,9 +17,19 @@ typedef struct { } Position; // The forward declaration of the component id variable. This variable will have -// the name FLECS__EPosition, to ensure its name won't conflict with the type. +// the name FLECS_IDPositionID, to ensure its name won't conflict with the type. ECS_COMPONENT_DECLARE(Position); +// When you want forward declare a component from a header, make sure to use the +// extern keyword to prevent multiple definitions of the same variable: +// +// In the header: +// extern ECS_COMPONENT_DECLARE(Position); +// +// In *one* of the source files: +// ECS_COMPONENT_DECLARE(Position); + + // To forward declare entities created with ECS_ENTITY, ECS_TAG or ECS_PREFAB, // use ECS_DECLARE. ECS_DECLARE(Wizard); diff --git a/examples/cpp/queries/find_entity/src/main.cpp b/examples/cpp/queries/find_entity/src/main.cpp index 829eff7618..9b7d687f43 100644 --- a/examples/cpp/queries/find_entity/src/main.cpp +++ b/examples/cpp/queries/find_entity/src/main.cpp @@ -2,7 +2,7 @@ #include struct Position { - double x, y; + int x, y; }; int main() { @@ -16,7 +16,7 @@ int main() { // Find the entity for which Position.x is 20 flecs::entity e = q.find([](Position& p) { - return p.x == 20.0; + return p.x == 20; }); if (e) {