Last active
October 2, 2018 15:38
-
-
Save heatblazer/ba8f0ea0d30be04eff8bfd253ab82261 to your computer and use it in GitHub Desktop.
hello-serialization-c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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