home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / kpathsea / c-vararg.h < prev    next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  62 lines

  1. /* c-vararg.h: Top layer for stdarg and varargs.
  2.  
  3. Copyright (C) 1993 Karl Berry.
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  18.  
  19. #ifndef C_VARARG_H
  20. #define C_VARARG_H
  21.  
  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.  */
  27.  
  28. #ifdef HAVE_PROTOTYPES
  29. #include <stdarg.h>
  30.  
  31. #define PVAR1H(p1) (p1, ...)
  32. #define PVAR2H(p1, p2) (p1, p2, ...)
  33. #define PVAR3H(p1, p2, p3) (p1, p2, p3, ...)
  34.  
  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);
  41.  
  42. #else /* not HAVE_PROTOTYPES */
  43. #include <varargs.h>
  44.  
  45. #define PVAR1H(p1) ()
  46. #define PVAR2H(p1, p2) ()
  47. #define PVAR3H(p1, p2, p3) ()
  48.  
  49. #define PVAR1C(t1, n1,  ap) \
  50.   (va_alist) va_dcl { t1 n1; va_list ap; va_start (ap); \
  51.                       n1 = va_arg (ap, t1);
  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); \
  58.                       n3 = va_arg (ap, t3);
  59. #endif /* not HAVE_PROTOTYPES */
  60.  
  61. #endif /* not C_VARARG_H */
  62.