title: How to use macro in lua
body: <p>Was looking now few threads on lua and found this post very interesting:</p>
  
  <p><a href="https://stackoverflow.com/questions/33652665/alert-messages-for-lua-functions/33655587?noredirect=1#comment55085565_33655587">Alert messages for lua functions</a></p>
  
  <p>I am trying to use the same macro to my code with some changes to operation:</p>
  
  <pre><code>#define GET_INTEGER_WARN(ind, fld) do { \
  lua_getfield(L, ind, #fld); \
  p-&gt;##fld = lua_tointeger(L, -1); \
  \
  if (!lua_isinteger(L, -1)) \
      printf(#fld" allows only numbers;"); \
  } while (0)
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>lua_getfield(L, -1, "wooxy_value"); 
  p-&gt;wooxy_value = lua_tointeger(L, -1);
  
  lua_getfield(L, -2, "wooxy_type"); 
  p-&gt;wooxy_type = lua_tointeger(L, -1);
  </code></pre>
  
  <p>I changed my code as the author explain, thus:</p>
  
  <pre><code>GET_INTEGER_WARN(-1, "wooxy_value");  
  GET_INTEGER_WARN(-2, "wooxy_type"); 
  </code></pre>
  
  <p>More macro error occurs at the following location:</p>
  
  <pre><code>p-&gt;##fld = lua_tointeger(L, -1); \
  </code></pre>
  
  <p>compilation erro: <code>error c2059 syntax error 'string'</code></p>
  
  <p>I did a test and replaces the function <code>p-&gt;##fld</code> by <code>p-&gt;wooxy_value</code> and it worked.</p>
  
  <p>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.</p>