va_start
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Relational operators (deprecated in C++20)
Integer comparison functions
Swap and type operations
Common vocabulary types
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Defined in header
<cstdarg>
void va_start( std::va_list ap, parm_n );
The va_start
macro enables access to the variable arguments following the named argument parm_n.
va_start
should be invoked with an instance to a valid va_list object ap before any calls to va_arg .
If the parm_n is a pack expansion or an entity resulting from a lambda capture, the program is ill-formed, no diagnostic required.
(since C++11)If parm_n is of reference type, or of a type not compatible with the type that results from default argument promotions, the behavior is undefined.
[edit] Parameters
ap
-
an object of the va_list type
parm_n
-
the named parameter preceding the first variable parameter
[edit] Expanded value
(none)
[edit] Notes
va_start
is required to support parm_n with overloaded operator&
.
[edit] Example
Run this code
Output:
150
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
CWG 273 | C++98 | it was unclear whether va_start is required tosupport parm_ns with overloaded operator&
|
required |
LWG 2099 | C++98 | the behavior was undefined if parm_n is declared with a function, array, or reference type |
the behavior is undefined if parm_n is of reference type |
[edit] See also
C documentation for va_start