Back to index

tetex-bin  3.0
c-vararg.h
Go to the documentation of this file.
00001 /* c-vararg.h: Top layer for stdarg and varargs.
00002 
00003 Copyright (C) 1993 Karl Berry.
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Library General Public
00007 License as published by the Free Software Foundation; either
00008 version 2 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Library General Public License for more details.
00014 
00015 You should have received a copy of the GNU Library General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00018 
00019 #ifndef C_VARARG_H
00020 #define C_VARARG_H
00021 
00022 /* See function `init_path' in `kpathsea/tex-file.c' for an example of use.
00023    The idea is to say PVAR1C(type1, parameter1, ap) in the function header,
00024    and then end the function with two }}'s.  We do this to avoid having to
00025    specify the argument list (with types) twice -- once in the function
00026    header, and once in a (hypothetical) VA_START1.  */
00027 
00028 #ifdef HAVE_PROTOTYPES
00029 #include <stdarg.h>
00030 
00031 #define PVAR1H(p1) (p1, ...)
00032 #define PVAR2H(p1, p2) (p1, p2, ...)
00033 #define PVAR3H(p1, p2, p3) (p1, p2, p3, ...)
00034 
00035 #define PVAR1C(t1, n1,  ap) \
00036   (t1 n1, ...) { va_list ap; va_start (ap, n1);
00037 #define PVAR2C(t1, n1,  t2, n2,  ap) \
00038   (t1 n1, t2 n2, ...) { va_list ap; va_start (ap, n2);
00039 #define PVAR3C(t1, n1,  t2, n2,  t3, n3,  ap) \
00040   (t1 n1, t2 n2, t3 n3, ...) { va_list ap; va_start (ap, n3);
00041 
00042 #else /* not HAVE_PROTOTYPES */
00043 #include <varargs.h>
00044 
00045 #define PVAR1H(p1) ()
00046 #define PVAR2H(p1, p2) ()
00047 #define PVAR3H(p1, p2, p3) ()
00048 
00049 #define PVAR1C(t1, n1,  ap) \
00050   (va_alist) va_dcl { t1 n1; va_list ap; va_start (ap); \
00051                       n1 = va_arg (ap, t1);
00052 #define PVAR2C(t1, n1,  t2, n2,  ap) \
00053   (va_alist) va_dcl { t1 n1; t2 n2; va_list ap; va_start (ap); \
00054                       n1 = va_arg (ap, t1); n2 = va_arg (ap, t2);
00055 #define PVAR3C(t1, n1,  t2, n2,  t3, n3,  ap) \
00056   (va_alist) va_dcl { t1 n1; t2 n2; t3 n3; va_list ap; va_start (ap); \
00057                       n1 = va_arg (ap, t1); n2 = va_arg (ap, t2); \
00058                       n3 = va_arg (ap, t3);
00059 #endif /* not HAVE_PROTOTYPES */
00060 
00061 #endif /* not C_VARARG_H */