Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The compiler is likely complaining about the trailing comma when the variadic arguments list is empty. GCC and Visual Studio compilers support the non-standard extension <code>##__VA_ARGS__</code> to suppress the trailing comma:</p> <pre><code>#define FOO(fmt, ...) printf(fmt, ##__VA_ARGS__) </code></pre> <p>The Visual Studio compilers will also suppress the trailing comma even without the <code>##</code> extension.</p> <p>See GCC documentation <a href="http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html" rel="nofollow noreferrer">here</a>, and Visual Studio documentation <a href="http://msdn.microsoft.com/en-us/library/ms177415.aspx" rel="nofollow noreferrer">here</a>.</p> <p>If you need a standards-compliant solution, there is one detailed in an answer to <a href="https://stackoverflow.com/questions/5588855/standard-alternative-to-gccs-va-args-trick">this question</a>.</p> <p>So if you are using either gcc or Visual Studio, you should be able to use your original macro with this simple change:</p> <pre><code>#define CCB_CREATE(object_type,...) \ static CCNode * create##object_type##Node() { \ std::map&lt;std::string, CCNodeLoader*&gt; loader_map; \ std::string classname = #object_type; \ FOR_EACH(INSERT_LOADER_MAP,object_type,##__VA_ARGS__); \ return loadCCBFile((classname + ".ccbi").c_str(), loader_map); \ } </code></pre> <p><strong>Edit:</strong> You would need to use the <code>##__VA_ARGS__</code> extension in the <code>FOR_EACH()</code> macro as well, or the more elegant modification suggested by ugoren.</p> <pre><code>#define FOR_EACH(what, x, ...) FOR_EACH_(FOR_EACH_NARG(x, ##__VA_ARGS__), what, x, __VA_ARGS__) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload