Skip to content

Order of module imports affect availability of Units #1300

@domdom

Description

@domdom

Describe the bug
Importing the 'flecs::stats' module before the 'flecs::units' module results in an error message when trying to register a component member as having a given Unit type.

To Reproduce
Consider the following code:

#include <flecs.h>

int main() {

    flecs::world world;
    world.import<flecs::stats>();
    world.import<flecs::units>();

    struct Foo {
        float x;
    };

    world.component<Foo>().member<flecs::units::length::Meters>("x", &Foo::x);

    return 0;
}

Running that code emits the following:

error: meta.c: 392: entity 'Meters' for member 'x' is not a unit

Swapping the order of those two imports fixes the issue.

NB: This is running on v4.0.0 of flecs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions