Unless my understanding is incorrect, the following macro
int i; // for loop
const char* ctype; // proprietary type string
void** pool = malloc(sizeof(void*) * (nexpected - 1));
size_t poolc = 0;
#define SET(type, fn) type* v = (pool[poolc++] = malloc(sizeof(type)));         \
    *v = (type) fn(L, i)
#define CHECK(chr, type, fn) case chr:                                          \
    SET(type, fn);                                                              \
    break
switch (ctype[0]) {
  CHECK('c', char, lua_tonumber);
}
should expand to
int i; // for loop
const char* ctype; // proprietary type string
void** pool = malloc(sizeof(void*) * (nexpected - 1));
size_t poolc = 0;
switch (ctype[0]) {
  case 'c':
    char* v = (pool[poolc++] = malloc(sizeof(char)));
    *v = (char) lua_tonumber(L, i);
    break;
}
but upon compilation, I get:
src/lua/snip.m:185:16: error: expected expression
    CHECK('c', char, lua_tonumber);
               ^
src/lua/snip.m:181:9: note: expanded from macro 'CHECK'
    SET(type, fn);                                                              \
        ^
src/lua/snip.m:178:23: note: expanded from macro 'SET'
#define SET(type, fn) type* v = (pool[poolc++] = malloc(sizeof(type)));         \
                      ^
src/lua/snip.m:185:5: error: use of undeclared identifier 'v'
    CHECK('c', char, lua_tonumber);
    ^
src/lua/snip.m:181:5: note: expanded from macro 'CHECK'
    SET(type, fn);                                                              \
    ^
src/lua/snip.m:179:6: note: expanded from macro 'SET'
    *v = (type) fn(L, i)
     ^
2 errors generated.
What is going on here? Isn't the preprocessor a literal text replacement engine? Why is it trying to evaluate expressions?
Keep in mind while this looks like straight C, this is actually clang Objective C (note the .m) under the C11 standard. Not sure if that makes any difference.
I'm a loss at how to continue without expanding the code for each entry.
 
    