Is this a valid way of checking if a variadic macro argument list is empty? : <p>I've been looking for a way to check if a variadic macro argument list is empty. All solutions I find seem to be either quite complex or using non-standard extensions. </p>

<p>I think I've found an easy solution that is both compact and standard:</p>

<pre><code>#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 )
</code></pre>

<p>Q: Are there any circumstances where my solution will fail or invoke poorly-defined behavior?</p>

<p>Based on C17 6.10.3.2/2 (the # operator): <em>"The character string literal corresponding to an empty argument is <code>""</code>"</em>, I believe that <code>#__VA_ARGS__</code> is always well-defined. </p>

<p>Explanation of the macro:</p>

<ul>
<li>This creates a compound literal char array and initializes it by using a string literal.</li>
<li>No matter what is passed to the macro, all arguments will be translated to one long string literal. </li>
<li>In case the macro list is empty, the string literal will become <code>""</code>, which consists only of a null terminator and therefore has size 1. </li>
<li>In all other cases, it will have a size greater than 1.</li>
</ul>
