Skip to content

Instantly share code, notes, and snippets.

@heatblazer
Last active October 2, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heatblazer/ba8f0ea0d30be04eff8bfd253ab82261 to your computer and use it in GitHub Desktop.
Save heatblazer/ba8f0ea0d30be04eff8bfd253ab82261 to your computer and use it in GitHub Desktop.
hello-serialization-c
/** object.def - generate this file
INT(x)
INT(y)
PDATA()
*/
#include <stdio.h>
#define INT(x) int x;
#define INT(y) int y;
#define PDATA() char* data;
struct Object
{
#include "object.def"
// do some extra stuff
};
// test simple char pool
static char g_DataPool[2][256] = {{0}};
int main()
{
struct Object ob;
ob.x = 100;
ob.y = 200;
ob.data = &g_DataPool[0];
snprintf(ob.data, 256, "%s", "Test data!!!");
printf("%d %d %s\r\n", ob.x, ob.y, ob.data);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment