1. Changelog
1.1. Revision 0 - October 1st, 2024
-
Initial release. ✨
2. Introduction & Motivation
This paper is a pure editorial change for properly classifying the various parts of function declarations/definitions in C, as there is misleading/confusing terminology surrounding these terms as illustrated by N6559.
3. Possible WG14 Direction?
Two possible names for both sets of things:
-
"varying functions" or "variadic functions"
-
"varying arguments" or "variadic arguments"
Standard currently uses "variable arguments" in places, which strangely I rarely hear in the wild unless directly referencing the title of the clause 7.16.1
.
4. Wording
The following wording is registered against the latest working draft as of October 1st, 2024.
4.1. Modify §6.5.5.3 to use variadic
-
Change "The ellipsis notation in a
function prototype declarator…" to "The ellipsis notation in a variadic function declarator (6.7.7.4) …".
4.2. Modify §6.7.7.4 to define variadic functions
6.7.7.4Functions declarators…If the list terminates with an ellipsis (...), no information about the number or types of the parameters after the comma is supplied. Declarators with the ellipses in a parameter list are known as variadic functions. Arguments supplied to a function whose positions match or come after the ellipsis in the parameter list are its varying arguments.
…For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists shall agree in the number of parameters and
in use of the final ellipsiswhether the function is variadic or not ; …162)The macros defined in the
header (7.16) can be used to access arguments that correspond to the ellipsis in variadic functions .
< stdarg . h >
4.3. Modify §6.9.2 to define the types/parts of a function
6.9.2Functions definitions…If
a function that accepts a variable number of argumentsa declarator for a variadic function is later defined as a non-variadic function, the behavior is undefined.The parameter type list, the attribute specifier sequence of the declarator that follows the parameter type list, and the compound statement of the function body form a single block.193) The block defined by just the compound statement of a function body, without its parameter type list or attribute specifier sequence, is known as the function body block. Each parameter has automatic storage duration; its identifier, if any,194) is an lvalue.195) The layout of the storage for parameters is unspecified.
4.4. Modify §7.16
-
Change 7.16 title from "
Variable arguments" to Varying arguments< stdarg . h >
".< stdarg . h > -
Rewrite "
The header" or equivalent text from paragraph 1 to " The header
declares a type and defines five macros, for advancing through a list of arguments whose number and types are not known to the called function when it is translated.< stdarg . h >
declares a type and defines five macros and functions, for use with variadic functions and varying arguments. "< stdarg . h > -
Remove "
A function may be called with a variable number of arguments of varying types if its parameter type list ends with an ellipsis." or equivalent text from paragraph 3. -
Change 7.16.2 title from "
Variable argumentlist access macros" to " Varying argument list access macros". -
Change "The
macro may only be invoked in theva_start compound-statement of the bodyof a variadic function." or equivalent to "The
macro may only be invoked in the function body block of a variadic function." from paragraph 2.va_start
4.5. Find-and-replace Changes
-
Find all leftover occurrences of "function with a variable number of arguments" and change to "variadic function" throughout the standard.
-
Find all leftover occurrences of "function with variable number of arguments" and change to "variadic function" throughout the standard.
-
Find all leftover occurrences of "variable argument" and change to "varying arguments" throughout the standard.