Skip to content

Instantly share code, notes, and snippets.

@malkia
Last active August 29, 2015 13:56
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 malkia/8825584 to your computer and use it in GitHub Desktop.
Save malkia/8825584 to your computer and use it in GitHub Desktop.
/* Stolen from luajit - http://repo.or.cz/w/luajit-2.0.git/blob/HEAD:/src/lj_obj.h */
/* Look for examples here - http://repo.or.cz/w/luajit-2.0.git/blob/HEAD:/src/lj_meta.c */
/* ANd http://repo.or.cz/w/luajit-2.0.git/blob/HEAD:/src/lj_obj.c */
#define MYDEFS(_) _(one) _(two) _(three) _(four) _(five)
/* Make an enum from 'one', 'two', etc. */
typedef enum my_enums{
#define MYENUM(name) my_##name,
MYDEFS(MYENUM)
#undef MYENUM
my_max
} my_enums;
/* Make an array of strings strings[]={ "one", "two", ... } */
const char* my_enum_strings[] = {
#define MYENUMSTRING(name) #name,
MYDEFS(MYENUMSTRING)
#undef MYENUMSTRING
};
/* Make an OpenGL like capability string=" one two three "; */
const char* my_string =
#define MYSTRING(name) #name " "
MYDEFS(MYSTRING)
#undef MYSTRING
;
/* Not tested - wrote by collecting samples from luajit */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment