Talk:Variadic macro in the C preprocessor

Unnamed section
It should be said how the user (= body of the function) accesses to (possibly existing) extra arguments and their number. &mdash; MFH: Talk 19:07, 12 May 2005 (UTC)

now you (Akihabara) added "no means is provided...", although I somehow remember some trick to find it out (but I stopped doing tricky things in C about 10 years ago...) - but maybe the tricks I used then are too tricky to be mentioned officially...(kindof calculations with stack pointers, return adresses sneaked from the stack, memory addresses of passed parameters, etc.etc.) - but wasn't there some simple (and official) VA_NUM_ARGS macro or so? &mdash; MFH: Talk 19:14, 13 May 2005 (UTC)


 * No. There may be compiler extensions, but there is no way for the macro itself to find out.  Note this has nothing to do with stacks; you may be getting confused with variadic functions --Akihabara 22:49, 13 May 2005 (UTC)

The page says "Previous versions of Visual Studio lack this feature", but I'm compiling some variadic macros in VS 2003. --anon

more arguments
What happens if you use ? That is: using a variadic macro with a different number of variables. That's what the variadic macros are good for, right? I don't see how this is supposed to work. --Abdull 09:24, 4 December 2007 (UTC)
 * The stdarg.h article describes how it works. . --Abdull 09:36, 4 December 2007 (UTC)

fewer arguments
It's worth mentioning the necessity to pass at least one argument to fill the '...' slot, distinct from variadic functions. In the variadic case C99 demands more arguments than identifiers in the definition (see ISO/EOC9899:TC3 6.10.3 constraint 4), but compilers often allow zero extra arguments. Even so, if  is allowed to expand to an empty string then an expression like would expand to where a trailing comma is left in the argument list. --212.44.20.129 (talk) 20:01, 11 February 2009 (UTC)


 * And the Microsoft C/C++ compiler caters for that case by dropping the trailing comma
 * Yes, we probably should add this to the article somehow...
 * Mark Hurd (talk) 01:16, 24 February 2009 (UTC)

This article is wrong. The preprocessor does NOTHING to fix the dangling comma if you have no variadic arguments. GCC and VC++ have extensions to fix it, but the standard does not. You need at least one argument. The workaround is to just specify all arguments as variadic:


 * 1) define foo(...) —Preceding unsigned comment added by 74.69.152.178 (talk) 14:31, 11 February 2011 (UTC)

Fixed o11c (talk) 02:56, 23 December 2011 (UTC)

The 'impossible example' section is wrong and doesn't respect the encyclopedic style:

- The definition of MYLOG doesn't even use #define - The expansion of  isn't right, it doesn't even include the  __FILE__ and __LINE__ values. - The line "There's no way to fix this behaviour!" doesn't belong in wikipedia

216.16.247.154 (talk) 20:01, 28 September 2012 (UTC)

Not an ellipsis
The article says an ellipsis is used to declare a variadic macro. This is wrong. A variadic macro is declared with three dots ("...", or "\u002E\u002E\u002E"), not with an ellipsis ("…" or "\u2026"). — Preceding unsigned comment added by 91.151.76.100 (talk) 08:58, 26 September 2013 (UTC)

Requested move 6 April 2021

 * The following is a closed discussion of a requested move. Please do not modify it. Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a move review after discussing it on the closer's talk page. No further edits should be made to this discussion. 

The result of the move request was: moved. (closed by non-admin page mover) ~ Aseleste  (t, e &#124; c, l) 01:05, 22 April 2021 (UTC)

Variadic macro → Variadic macro in the C preprocessor – Countless other languages have variadic macros, but do not seem to fit into the article (on one hand due to its organization, on the other hand due to systems that don't work on text substitution). Artoria2e5 🌉 08:05, 6 April 2021 (UTC) —Relisting. Extraordinary Writ (talk) 22:45, 14 April 2021 (UTC) The discussion above is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Post-closure cleanup
@Artoria2e5: You may want to edit the article to remove references to non-C preprocessors. I will leave it up to you on deciding what to do with the newly created redirect Variadic macro, whether it be leaving it alone, converting it to an article, or nominating it for WP:RfD. ~ Aseleste  (t, e &#124; c, l) 01:17, 22 April 2021 (UTC)