1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
/* SCCS Id: @(#)tradstdc.h 3.4 1993/05/30 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef TRADSTDC_H
#define TRADSTDC_H
#if defined(DUMB) && !defined(NOVOID)
#define NOVOID
#endif
#ifdef NOVOID
#define void int
#endif
/*
* Borland C provides enough ANSI C compatibility in its Borland C++
* mode to warrant this. But it does not set __STDC__ unless it compiles
* in its ANSI keywords only mode, which prevents use of <dos.h> and
* far pointer use.
*/
#if (defined(__STDC__) || defined(__TURBOC__)) && !defined(NOTSTDC)
#define NHSTDC
#endif
#if defined(ultrix) && defined(__STDC__) && !defined(__LANGUAGE_C)
/* Ultrix seems to be in a constant state of flux. This check attempts to
* set up ansi compatibility if it wasn't set up correctly by the compiler.
*/
#ifdef mips
#define __mips mips
#endif
#ifdef LANGUAGE_C
#define __LANGUAGE_C LANGUAGE_C
#endif
#endif
/*
* ANSI X3J11 detection.
* Makes substitutes for compatibility with the old C standard.
*/
/* Decide how to handle variable parameter lists:
* USE_STDARG means use the ANSI <stdarg.h> facilities (only ANSI compilers
* should do this, and only if the library supports it).
* USE_VARARGS means use the <varargs.h> facilities. Again, this should only
* be done if the library supports it. ANSI is *not* required for this.
* Otherwise, the kludgy old methods are used.
* The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for
* others.
*/
/* #define USE_VARARGS */ /* use <varargs.h> instead of <stdarg.h> */
/* #define USE_OLDARGS */ /* don't use any variable argument facilites */
#if defined(apollo) /* Apollos have stdarg(3) but not stdarg.h */
# define USE_VARARGS
#endif
#if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(MAC)
# if !defined(USE_VARARGS) && !defined(USE_OLDARGS) && !defined(USE_STDARG)
# define USE_STDARG
# endif
#endif
#ifdef NEED_VARARGS /* only define these if necessary */
#ifdef USE_STDARG
#include <stdarg.h>
# define VA_DECL(typ1,var1) (typ1 var1, ...) { va_list the_args;
# define VA_DECL2(typ1,var1,typ2,var2) \
(typ1 var1, typ2 var2, ...) { va_list the_args;
# define VA_INIT(var1,typ1)
# define VA_NEXT(var1,typ1) var1 = va_arg(the_args, typ1)
# define VA_ARGS the_args
# define VA_START(x) va_start(the_args, x)
# define VA_END() va_end(the_args)
# if defined(ULTRIX_PROTO) && !defined(_VA_LIST_)
# define _VA_LIST_ /* prevents multiple def in stdio.h */
# endif
#else
# ifdef USE_VARARGS
#include <varargs.h>
# define VA_DECL(typ1,var1) (va_alist) va_dcl {\
va_list the_args; typ1 var1;
# define VA_DECL2(typ1,var1,typ2,var2) (va_alist) va_dcl {\
va_list the_args; typ1 var1; typ2 var2;
# define VA_ARGS the_args
# define VA_START(x) va_start(the_args)
# define VA_INIT(var1,typ1) var1 = va_arg(the_args, typ1)
# define VA_NEXT(var1,typ1) var1 = va_arg(the_args,typ1)
# define VA_END() va_end(the_args)
# else
# define VA_ARGS arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9
# define VA_DECL(typ1,var1) (var1,VA_ARGS) typ1 var1; \
char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
# define VA_DECL2(typ1,var1,typ2,var2) (var1,var2,VA_ARGS) \
typ1 var1; typ2 var2;\
char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
# define VA_START(x)
# define VA_INIT(var1,typ1)
# define VA_END()
# endif
#endif
#endif /* NEED_VARARGS */
#if defined(NHSTDC) || defined(MSDOS) || defined(MAC) || defined(ULTRIX_PROTO) || defined(__BEOS__)
/*
* Used for robust ANSI parameter forward declarations:
* int VDECL(sprintf, (char *, const char *, ...));
*
* NDECL() is used for functions with zero arguments;
* FDECL() is used for functions with a fixed number of arguments;
* VDECL() is used for functions with a variable number of arguments.
* Separate macros are needed because ANSI will mix old-style declarations
* with prototypes, except in the case of varargs, and the OVERLAY-specific
* trampoli.* mechanism conflicts with the ANSI <<f(void)>> syntax.
*/
# define NDECL(f) f(void) /* overridden later if USE_TRAMPOLI set */
# define FDECL(f,p) f p
# if defined(MSDOS) || defined(USE_STDARG)
# define VDECL(f,p) f p
# else
# define VDECL(f,p) f()
# endif
/* generic pointer, always a macro; genericptr_t is usually a typedef */
# define genericptr void *
# if (defined(ULTRIX_PROTO) && !defined(__GNUC__)) || defined(OS2_CSET2)
/* Cover for Ultrix on a DECstation with 2.0 compiler, which coredumps on
* typedef void * genericptr_t;
* extern void a(void(*)(int, genericptr_t));
* Using the #define is OK for other compiler versions too.
*/
/* And IBM CSet/2. The redeclaration of free hoses the compile. */
# define genericptr_t genericptr
# else
# if !defined(NHSTDC) && !defined(MAC)
# define const
# define signed
# define volatile
# endif
# endif
/*
* Suppress `const' if necessary and not handled elsewhere.
* Don't use `#if defined(xxx) && !defined(const)'
* because some compilers choke on `defined(const)'.
* This has been observed with Lattice, MPW, and High C.
*/
# if (defined(ULTRIX_PROTO) && !defined(NHSTDC)) || defined(apollo)
/* the system header files don't use `const' properly */
# ifndef const
# define const
# endif
# endif
#else /* NHSTDC */ /* a "traditional" C compiler */
# define NDECL(f) f()
# define FDECL(f,p) f()
# define VDECL(f,p) f()
# if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC) || defined(__BORLANDC__)
# define genericptr void *
# endif
# ifndef genericptr
# define genericptr char *
# endif
/*
* Traditional C compilers don't have "signed", "const", or "volatile".
*/
# define signed
# define const
# define volatile
#endif /* NHSTDC */
#ifndef genericptr_t
typedef genericptr genericptr_t; /* (void *) or (char *) */
#endif
/*
* According to ANSI, prototypes for old-style declarations must widen the
* arguments to int. However, the MSDOS compilers accept shorter arguments
* (char, short, etc.) in prototypes and do typechecking with them. Therefore
* this mess to allow the better typechecking while also allowing some
* prototypes for the ANSI compilers so people quit trying to fix the
* prototypes to match the standard and thus lose the typechecking.
*/
#if defined(MSDOS) && !defined(__GO32__)
#define UNWIDENED_PROTOTYPES
#endif
#if defined(AMIGA) && !defined(AZTEC_50)
#define UNWIDENED_PROTOTYPES
#endif
#if defined(macintosh) && (defined(__SC__) || defined(__MRC__))
#define WIDENED_PROTOTYPES
#endif
#if defined(__MWERKS__) && defined(__BEOS__)
#define UNWIDENED_PROTOTYPES
#endif
#if defined(WIN32)
#define UNWIDENED_PROTOTYPES
#endif
#if defined(ULTRIX_PROTO) && defined(ULTRIX_CC20)
#define UNWIDENED_PROTOTYPES
#endif
#if defined(apollo)
#define UNWIDENED_PROTOTYPES
#endif
#ifndef UNWIDENED_PROTOTYPES
# if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(THINK_C)
# define WIDENED_PROTOTYPES
# endif
#endif
#if 0
/* The problem below is still the case through 4.0.5F, but the suggested
* compiler flags in the Makefiles suppress the nasty messages, so we don't
* need to be quite so drastic.
*/
#if defined(__sgi) && !defined(__GNUC__)
/*
* As of IRIX 4.0.1, /bin/cc claims to be an ANSI compiler, but it thinks
* it's impossible for a prototype to match an old-style definition with
* unwidened argument types. Thus, we have to turn off all NetHack
* prototypes, and avoid declaring several system functions, since the system
* include files have prototypes and the compiler also complains that
* prototyped and unprototyped declarations don't match.
*/
# undef NDECL
# undef FDECL
# undef VDECL
# define NDECL(f) f()
# define FDECL(f,p) f()
# define VDECL(f,p) f()
#endif
#endif
/* MetaWare High-C defaults to unsigned chars */
/* AIX 3.2 needs this also */
#if defined(__HC__) || defined(_AIX32)
# undef signed
#endif
/*
* Allow gcc2 to check parameters of printf-like calls with -Wformat;
* append this to a prototype declaration (see pline() in extern.h).
*/
#ifdef __GNUC__
# if __GNUC__ >= 2
#define PRINTF_F(f,v) __attribute__ ((format (printf, f, v)))
# endif
#endif
#ifndef PRINTF_F
#define PRINTF_F(f,v)
#endif
#endif /* TRADSTDC_H */
|