home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / kpathsea / c-vararg.h < prev    next >
C/C++ Source or Header  |  1994-02-23  |  2KB  |  62 lines

  1. /* c-vararg.h: Top layer for stdarg and varargs.
  2.  
  3. Copyright (C) 1993 Karl Berry.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program 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
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef C_VARARG_H
  20. #define C_VARARG_H
  21.  
  22. /* See `kpathsea/init-path.c' for an example of use.  The idea is to say
  23.    PVAR1(type1, parameter1, ap) in the function header, and then end
  24.    the function with two }}'s.  We do this to avoid having to specify
  25.    the argument list (with types) twice -- once in the function header,
  26.    and once in a (hypothetical) VA_START1.  */
  27.  
  28. #if __STDC__
  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 __STDC__ */
  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 __STDC__ */
  60.  
  61. #endif /* not C_VARARG_H */
  62.