Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef AUTO_DEFINE_STRUCT_H
|
||||
#define AUTO_DEFINE_STRUCT_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "auto_define_struct/bake_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
)
|
||||
(.)
|
||||
.|.
|
||||
| |
|
||||
_.--| |--._
|
||||
.-'; ;`-'& ; `&.
|
||||
\ & ; & &_/
|
||||
|"""---...---"""|
|
||||
\ | | | | | | | /
|
||||
`---.|.|.|.---'
|
||||
|
||||
* This file is generated by bake.lang.c for your convenience. Headers of
|
||||
* dependencies will automatically show up in this file. Include bake_config.h
|
||||
* in your main project file. Do not edit! */
|
||||
|
||||
#ifndef AUTO_DEFINE_STRUCT_BAKE_CONFIG_H
|
||||
#define AUTO_DEFINE_STRUCT_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "auto_define_struct",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"author": "Jane Doe",
|
||||
"description": "A simple hello world flecs application",
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <auto_define_struct.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// This type captured is used later to inject reflection data for Position
|
||||
ECS_STRUCT(Position, {
|
||||
float x;
|
||||
float y;
|
||||
});
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
|
||||
|
||||
// This registers the component with reflection data
|
||||
ECS_META_COMPONENT(ecs, Position);
|
||||
|
||||
// Serialize as usual
|
||||
Position value = {10, 20};
|
||||
char *json = ecs_ptr_to_json(ecs, ecs_id(Position), &value);
|
||||
printf("%s\n", json); // {"x": 10.0, "y": 20.0}
|
||||
ecs_os_free(json);
|
||||
|
||||
return ecs_fini(ecs);
|
||||
}
|
||||
Reference in New Issue
Block a user