3

I was searching for a description of the variadic functions in the C11 standard but the only information I found was barely mentioning the topic. Can someone show me reference to all topics about them that can be found in it?

What I've found myself so far is in §6.9.1.8:

If a function that accepts a variable number of arguments is defined without a parameter type list that ends with the ellipsis notation, the behavior is undefined.

And in §7.16 which describes the <stdarg.h> header file. However I highly doubt this is all the information which can be found about variadic functions in the standard.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
AnArrayOfFunctions
  • 3,452
  • 2
  • 29
  • 66
  • There are some more paragraphs relating to this. Basically, arguments passed for `...` in the parameter list are treated as if the function was defined without a prototype (i.e. default argument promotions apply). But more isn't really needed to specify variable argument lists. – fuz Jan 03 '16 at 14:51
  • You'll of course need `` in order to consume the variable arguments. – Kerrek SB Jan 03 '16 at 15:02
  • 3
    C11 draft standard, `6.7.6.3 Function declarators (including prototypes)`? – EOF Jan 03 '16 at 15:07

1 Answers1

5

Along with the chapters you pointed, I would recommend to check chapter §6.7.6.3 from C11 standard, which has some more information on Function declarators. To summarize,

  • Variadic function declaration : Chapter §6.7.6.3
  • Variadic function calls : Chapter §6.5.2.2
  • Variadic function definitions : Chapter §6.9.1
  • Variadic function argument list related macros and their usage: Chapter §7.16.1.1 - §7.16.1.4

However, there is no full-featured description of the variadic functions, compiled in the form of a complete chapter (if that is what you're looking for) in the standard itself, AFAIK.

You may want to have a look at the wiki entry to gain some more insight.

alk
  • 69,737
  • 10
  • 105
  • 255
Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
  • How are they supposed to be supported by compiler developers then? – AnArrayOfFunctions Jan 03 '16 at 15:17
  • 2
    @FISOCPP I did not get you. There are enough information to support a variadic function present in the standard, it's just not in the form of a _complete chapter_ or tutorial. May I ask which particular information you're looking for? – Sourav Ghosh Jan 03 '16 at 15:19