Last active
August 29, 2015 13:56
-
-
Save malkia/8825584 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* 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