1#include <nested_struct.h>
2#include <stdio.h>
3
4typedef struct {
5 float x, y;
6} Point;
7
8typedef struct {
9 Point start, stop;
10} Line;
11
12int main(int argc, char *argv[]) {
14
17
20 .members = {
23 }
24 });
25
28 .members = {
29 { .name =
"start", .type =
ecs_id(Point) },
30 { .name =
"stop", .type =
ecs_id(Point) }
31 }
32 });
33
35 ecs_set(ecs, ent, Line, {{10, 20}, {30, 40}});
36
37 const Line *ptr =
ecs_get(ecs, ent, Line);
39 printf("%s\n", str);
40 ecs_os_free(str);
41
43}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
FLECS_API char * ecs_ptr_to_expr(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into expression string.
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
ecs_entity_t ecs_new(ecs_world_t *world)
Create new entity ID.
#define ECS_COMPONENT(world, id)
Declare and define a component.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_get(world, entity, T)
Get a component.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.