The preprocessor splits macro arguments on commas. […] These macros conceptually take a single argument, but they’re declared to take variable arguments to avoid this problem. By taking
__VA_ARGS__to refer to “the argument”, multiple “arguments” with commas are reproduced in the macro’s output. You can take the same approach to make your own macros safe from this problem, although it only works on the last argument of a multi-argument macro.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.