boost/libs/vmd/doc/vmd_variadic_macros.qbk
2021-10-05 21:37:46 +02:00

38 lines
1.8 KiB
Plaintext

[/
(C) Copyright Edward Diener 2011-2015,2020
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:vmd_vmacros Using variadic macros]
Variadic macros, as specified by C++11, is a feature taken from the C99
specification. They are macros which take a final parameter denoted as
'...' which represents one or more final arguments to the macro as a
series of comma-separated tokens. In the macro expansion a special
keyword of `__VA_ARGS__` represents the comma-separated tokens. This
information when passed to a variadic macro I call 'variadic macro data',
which gives its name to this library. The more general term 'variadic data'
is used in this documentation to specify data passed to a macro which can
contain any number of macro tokens as a single macro parameter, such as is
found in Boost PP data types.
The library assumes variadic macro support. If a compiler does not support
variadic macros the macros in the library will fail with preprocessor errors.
In previous versions of this library variadic macro support was determined
by the value of the BOOST_PP_VARIADICS object-like macro from the Boost Preprocessor
library, so that if this macro returned 0, none of the macros in the
library would be defined. This is no longer the case since the Boost
preprocessor library now also requires variadic macro support and BOOST_PP_VARIADICS
always returns 1.
What this means for the end-user is that the compiler
must be used in C++11 or higher mode, or that a compiler in C++98/C++03 mode
supports variadic macros. A number of major compilers, including Visual C++,
gcc, and clang. do support variadic macros in C++98/C++03 mode, as long as
strict compliance to the C++98/C++03 standard is not turned on through that
compiler's compiler flags.
[endsect]