Was looking now few threads on lua and found this post very interesting:
Alert messages for lua functions
I am trying to use the same macro to my code with some changes to operation:
#define GET_INTEGER_WARN(ind, fld) do { \
lua_getfield(L, ind, #fld); \
p->##fld = lua_tointeger(L, -1); \
\
if (!lua_isinteger(L, -1)) \
printf(#fld" allows only numbers;"); \
} while (0)
my code:
lua_getfield(L, -1, "wooxy_value");
p->wooxy_value = lua_tointeger(L, -1);
lua_getfield(L, -2, "wooxy_type");
p->wooxy_type = lua_tointeger(L, -1);
I changed my code as the author explain, thus:
GET_INTEGER_WARN(-1, "wooxy_value");
GET_INTEGER_WARN(-2, "wooxy_type");
More macro error occurs at the following location:
p->##fld = lua_tointeger(L, -1); \
compilation erro: error c2059 syntax error 'string'
I did a test and replaces the function p->##fld
by p->wooxy_value
and it worked.
More in this way works only for a function, can anybody tell me what is wrong with the macro? The message is also appearing even using integer value.