1 /* c-vararg.h: top layer for stdarg and varargs.
3 Copyright 1993, 2008 Karl Berry.
4 Copyright 1998, 2005 Olaf Weber.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, see <http://www.gnu.org/licenses/>. */
22 /* See function `init_path' in `kpathsea/tex-file.c' for an example of use.
23 The idea is to say PVAR1C(type1, parameter1, ap) in the function header,
24 and then end the function with two }}'s. We do this to avoid having to
25 specify the argument list (with types) twice -- once in the function
26 header, and once in a (hypothetical) VA_START1. */
28 #ifdef HAVE_PROTOTYPES
31 #define PVAR1H(p1) (p1, ...)
32 #define PVAR2H(p1, p2) (p1, p2, ...)
33 #define PVAR3H(p1, p2, p3) (p1, p2, p3, ...)
35 #define PVAR1C(t1, n1, ap) \
36 (t1 n1, ...) { va_list ap; va_start (ap, n1);
37 #define PVAR2C(t1, n1, t2, n2, ap) \
38 (t1 n1, t2 n2, ...) { va_list ap; va_start (ap, n2);
39 #define PVAR3C(t1, n1, t2, n2, t3, n3, ap) \
40 (t1 n1, t2 n2, t3 n3, ...) { va_list ap; va_start (ap, n3);
42 #else /* not HAVE_PROTOTYPES */
46 #define PVAR2H(p1, p2) ()
47 #define PVAR3H(p1, p2, p3) ()
49 #define PVAR1C(t1, n1, ap) \
50 (va_alist) va_dcl { t1 n1; va_list ap; va_start (ap); \
52 #define PVAR2C(t1, n1, t2, n2, ap) \
53 (va_alist) va_dcl { t1 n1; t2 n2; va_list ap; va_start (ap); \
54 n1 = va_arg (ap, t1); n2 = va_arg (ap, t2);
55 #define PVAR3C(t1, n1, t2, n2, t3, n3, ap) \
56 (va_alist) va_dcl { t1 n1; t2 n2; t3 n3; va_list ap; va_start (ap); \
57 n1 = va_arg (ap, t1); n2 = va_arg (ap, t2); \
59 #endif /* not HAVE_PROTOTYPES */
61 #endif /* not C_VARARG_H */