public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Counting the number of arguments in __VA_ARGS__
@ 2013-12-12 13:08 Florian Weimer
  2013-12-12 13:21 ` vijay nag
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2013-12-12 13:08 UTC (permalink / raw)
  To: gcc-help

Is there a way to count the number of variadic macro arguments in C?

I found a way to check if the list is empty: examine 
sizeof(STR((__VA_ARGS__))) where STR is a macro that stringifies its 
argument.  If it is 3, __VA_ARGS__ is empty.  I wonder if there is a 
less hackish approach.

The macro arguments are expressions, but not of a uniform type, so an 
array-based approach does not work.

-- 
Florian Weimer / Red Hat Product Security Team

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-18 16:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-12 13:08 Counting the number of arguments in __VA_ARGS__ Florian Weimer
2013-12-12 13:21 ` vijay nag
2013-12-12 13:32   ` Florian Weimer
2013-12-18 16:10     ` Alexander Monakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).