Closed tanis2000 closed 1 year ago
What you need to do is:
in types.h, add extern
:
extern ECS_DECLARE(health_t);
in main.c, add the declaration:
ECS_DECLARE(health_t);
If you don't do that, the variable will get declared in each source file that includes the header, which leads to duplicate symbols.
Thanks. I didn't look at what the macros look like. So ECS_DECLARE is actually declaring a variable. Now it makes sense that it gets redeclared many times as I include the same header multiple times :) Thanks for pointing this out! Awesome project btw ;)
Thanks! You're right, I should probably make this more clear in the documentation.
I have a C99 project using flecs and the code is spread across different implementation .c files. I noticed that when I enable ASAN and use ECS_DECLARE and ECS_DEFINE, suddenly something different happens during compilation and I start getting errors about duplicate symbols.
As an example, I have the following (stripped down example):
types.h
main.c
hero.c
That leads to
Do you have any idea how to fix this issue?