home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c045 / 2.ddi / INCLUDE / VARARGS.H$ / VARARGS.bin
Encoding:
Text File  |  1992-01-01  |  1.3 KB  |  57 lines

  1. /***
  2. *varargs.h - XENIX style macros for variable argument functions
  3. *
  4. *    Copyright (c) 1985-1991, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *    This file defines XENIX style macros for accessing arguments of a
  8. *    function which takes a variable number of arguments.
  9. *    [System V]
  10. *
  11. ****/
  12.  
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16.  
  17. #if defined(_DLL) && !defined(_MT)
  18. #error Cannot define _DLL without _MT
  19. #endif
  20.  
  21. #if (defined(_MT) || defined(_WINDLL))
  22. #define _FARARG_ __far
  23. #else
  24. #define _FARARG_
  25. #endif
  26.  
  27. #if (_MSC_VER <= 600)
  28. #define __far       _far
  29. #endif
  30.  
  31. #ifdef __STDC__
  32. #error varargs.h incompatible with ANSI (use stdarg.h)
  33. #endif
  34.  
  35. #ifndef _VA_LIST_DEFINED
  36. typedef char _FARARG_ *va_list;
  37. #define _VA_LIST_DEFINED
  38. #endif
  39.  
  40. /*
  41.  * define a macro to compute the size of a type, variable or expression,
  42.  * rounded up to the nearest multiple of sizeof(int). This number is its
  43.  * size as function argument (Intel architecture). Note that the macro
  44.  * depends on sizeof(int) being a power of 2!
  45.  */
  46.  
  47. #define _INTSIZEOF(n)     ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
  48.  
  49. #define va_dcl va_list va_alist;
  50. #define va_start(ap) ap = (va_list)&va_alist
  51. #define va_arg(ap,t) ( *(t _FARARG_ *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
  52. #define va_end(ap) ap = (va_list)0
  53.  
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57.