home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / cecko / install / devcpp4920.exe / include / varargs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  2.7 KB  |  103 lines

  1. /*
  2.  * varargs.h
  3.  *
  4.  * Old, non-ANSI facilities for stepping through a list of function
  5.  * arguments of an unknown number and type.
  6.  * TODO: Has not been tested. Essentially it copies the GCC version.
  7.  *
  8.  * NOTE: I believe GCC supplies a version of this header as well (in
  9.  *       addition to stdarg.h and others). The GCC version is more
  10.  *       complex, to deal with many alternate systems, but it is
  11.  *       probably more trustworthy overall. It would probably be
  12.  *       better to use the GCC version.
  13.  *
  14.  * NOTE: These are incompatible with the versions in stdarg.h and should
  15.  *       NOT be mixed! All new code should use the ANSI compatible versions.
  16.  *
  17.  * This file is part of the Mingw32 package.
  18.  *
  19.  * Contributors:
  20.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  21.  *
  22.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  23.  *
  24.  *  This source code is offered for use in the public domain. You may
  25.  *  use, modify or distribute it freely.
  26.  *
  27.  *  This code is distributed in the hope that it will be useful but
  28.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  29.  *  DISCLAMED. This includes but is not limited to warranties of
  30.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  31.  *
  32.  * $Revision: 1.4 $
  33.  * $Author: cgf $
  34.  * $Date: 2000/02/05 04:04:59 $
  35.  *
  36.  */
  37.  
  38. #ifndef    __STRICT_ANSI__
  39.  
  40. #ifndef _VARARGS_H_
  41. #define _VARARGS_H_
  42.  
  43. /* All the headers include this file. */
  44. #include <_mingw.h>
  45.  
  46. /* 
  47.  * I was told that Win NT likes this.
  48.  */
  49. #ifndef _VA_LIST_DEFINED
  50. #define _VA_LIST_DEFINED
  51. #endif
  52.  
  53. #ifndef RC_INVOKED
  54.  
  55. #ifndef    _VA_LIST
  56. #define _VA_LIST
  57. #if defined __GNUC__ && __GNUC__ >= 3
  58. typedef __builtin_va_list va_list;
  59. #else
  60. typedef char* va_list;
  61. #endif
  62. #endif
  63.  
  64. /*
  65.  * Amount of space required in an argument list (ie. the stack) for an
  66.  * argument of type t.
  67.  */
  68. #define __va_argsiz(t)    \
  69.     (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
  70.  
  71. #define    va_alist    __builtin_va_alist
  72.  
  73. /*
  74.  * Used in old style argument lists IIRC. The ellipsis forces the compiler
  75.  * to realize this is a vararg function.
  76.  */
  77. #define va_dcl        int __builtin_va_alist; ...
  78.  
  79. #define va_start(ap)    \
  80.     ((ap) = ((va_list) &__builtin_va_alist))
  81. #define va_end(ap)    ((void)0)
  82.  
  83.  
  84. /*
  85.  * Increment ap to the next argument in the list while returing a
  86.  * pointer to what ap pointed to first, which is of type t.
  87.  *
  88.  * We cast to void* and then to t* because this avoids a warning about
  89.  * increasing the alignment requirement.
  90.  */
  91.  
  92. #define va_arg(ap, t)                    \
  93.      (((ap) = (ap) + __va_argsiz(t)),        \
  94.       *((t*) (void*) ((ap) - __va_argsiz(t))))
  95.  
  96.  
  97. #endif    /* Not RC_INVOKED */
  98.  
  99. #endif    /* Not _VARARGS_H_ */
  100.  
  101. #endif    /* Not __STRICT_ANSI__ */
  102.  
  103.