1
/* SCCS Id: @(#)tradstdc.h 3.4 1993/05/30 */
2
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3
/* NetHack may be freely redistributed. See license for details. */
8
#if defined(DUMB) && !defined(NOVOID)
17
* Borland C provides enough ANSI C compatibility in its Borland C++
18
* mode to warrant this. But it does not set __STDC__ unless it compiles
19
* in its ANSI keywords only mode, which prevents use of <dos.h> and
22
#if (defined(__STDC__) || defined(__TURBOC__)) && !defined(NOTSTDC)
26
#if defined(ultrix) && defined(__STDC__) && !defined(__LANGUAGE_C)
27
/* Ultrix seems to be in a constant state of flux. This check attempts to
28
* set up ansi compatibility if it wasn't set up correctly by the compiler.
35
#define __LANGUAGE_C LANGUAGE_C
41
* ANSI X3J11 detection.
42
* Makes substitutes for compatibility with the old C standard.
45
/* Decide how to handle variable parameter lists:
46
* USE_STDARG means use the ANSI <stdarg.h> facilities (only ANSI compilers
47
* should do this, and only if the library supports it).
48
* USE_VARARGS means use the <varargs.h> facilities. Again, this should only
49
* be done if the library supports it. ANSI is *not* required for this.
50
* Otherwise, the kludgy old methods are used.
51
* The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for
55
/* #define USE_VARARGS */ /* use <varargs.h> instead of <stdarg.h> */
56
/* #define USE_OLDARGS */ /* don't use any variable argument facilites */
58
#if defined(apollo) /* Apollos have stdarg(3) but not stdarg.h */
62
#if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(MAC)
63
# if !defined(USE_VARARGS) && !defined(USE_OLDARGS) && !defined(USE_STDARG)
68
#ifdef NEED_VARARGS /* only define these if necessary */
71
# define VA_DECL(typ1,var1) (typ1 var1, ...) { va_list the_args;
72
# define VA_DECL2(typ1,var1,typ2,var2) \
73
(typ1 var1, typ2 var2, ...) { va_list the_args;
74
# define VA_INIT(var1,typ1)
75
# define VA_NEXT(var1,typ1) var1 = va_arg(the_args, typ1)
76
# define VA_ARGS the_args
77
# define VA_START(x) va_start(the_args, x)
78
# define VA_END() va_end(the_args)
79
# if defined(ULTRIX_PROTO) && !defined(_VA_LIST_)
80
# define _VA_LIST_ /* prevents multiple def in stdio.h */
85
# define VA_DECL(typ1,var1) (va_alist) va_dcl {\
86
va_list the_args; typ1 var1;
87
# define VA_DECL2(typ1,var1,typ2,var2) (va_alist) va_dcl {\
88
va_list the_args; typ1 var1; typ2 var2;
89
# define VA_ARGS the_args
90
# define VA_START(x) va_start(the_args)
91
# define VA_INIT(var1,typ1) var1 = va_arg(the_args, typ1)
92
# define VA_NEXT(var1,typ1) var1 = va_arg(the_args,typ1)
93
# define VA_END() va_end(the_args)
95
# define VA_ARGS arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9
96
# define VA_DECL(typ1,var1) (var1,VA_ARGS) typ1 var1; \
97
char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
98
# define VA_DECL2(typ1,var1,typ2,var2) (var1,var2,VA_ARGS) \
99
typ1 var1; typ2 var2;\
100
char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; {
102
# define VA_INIT(var1,typ1)
106
#endif /* NEED_VARARGS */
108
#if defined(NHSTDC) || defined(MSDOS) || defined(MAC) || defined(ULTRIX_PROTO) || defined(__BEOS__)
111
* Used for robust ANSI parameter forward declarations:
112
* int VDECL(sprintf, (char *, const char *, ...));
114
* NDECL() is used for functions with zero arguments;
115
* FDECL() is used for functions with a fixed number of arguments;
116
* VDECL() is used for functions with a variable number of arguments.
117
* Separate macros are needed because ANSI will mix old-style declarations
118
* with prototypes, except in the case of varargs, and the OVERLAY-specific
119
* trampoli.* mechanism conflicts with the ANSI <<f(void)>> syntax.
122
# define NDECL(f) f(void) /* overridden later if USE_TRAMPOLI set */
124
# define FDECL(f,p) f p
126
# if defined(MSDOS) || defined(USE_STDARG)
127
# define VDECL(f,p) f p
129
# define VDECL(f,p) f()
132
/* generic pointer, always a macro; genericptr_t is usually a typedef */
133
# define genericptr void *
135
# if (defined(ULTRIX_PROTO) && !defined(__GNUC__)) || defined(OS2_CSET2)
136
/* Cover for Ultrix on a DECstation with 2.0 compiler, which coredumps on
137
* typedef void * genericptr_t;
138
* extern void a(void(*)(int, genericptr_t));
139
* Using the #define is OK for other compiler versions too.
141
/* And IBM CSet/2. The redeclaration of free hoses the compile. */
142
# define genericptr_t genericptr
144
# if !defined(NHSTDC) && !defined(MAC)
152
* Suppress `const' if necessary and not handled elsewhere.
153
* Don't use `#if defined(xxx) && !defined(const)'
154
* because some compilers choke on `defined(const)'.
155
* This has been observed with Lattice, MPW, and High C.
157
# if (defined(ULTRIX_PROTO) && !defined(NHSTDC)) || defined(apollo)
158
/* the system header files don't use `const' properly */
164
#else /* NHSTDC */ /* a "traditional" C compiler */
166
# define NDECL(f) f()
167
# define FDECL(f,p) f()
168
# define VDECL(f,p) f()
170
# if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC) || defined(__BORLANDC__)
171
# define genericptr void *
174
# define genericptr char *
178
* Traditional C compilers don't have "signed", "const", or "volatile".
188
typedef genericptr genericptr_t; /* (void *) or (char *) */
193
* According to ANSI, prototypes for old-style declarations must widen the
194
* arguments to int. However, the MSDOS compilers accept shorter arguments
195
* (char, short, etc.) in prototypes and do typechecking with them. Therefore
196
* this mess to allow the better typechecking while also allowing some
197
* prototypes for the ANSI compilers so people quit trying to fix the
198
* prototypes to match the standard and thus lose the typechecking.
200
#if defined(MSDOS) && !defined(__GO32__)
201
#define UNWIDENED_PROTOTYPES
203
#if defined(AMIGA) && !defined(AZTEC_50)
204
#define UNWIDENED_PROTOTYPES
206
#if defined(macintosh) && (defined(__SC__) || defined(__MRC__))
207
#define WIDENED_PROTOTYPES
209
#if defined(__MWERKS__) && defined(__BEOS__)
210
#define UNWIDENED_PROTOTYPES
213
#define UNWIDENED_PROTOTYPES
216
#if defined(ULTRIX_PROTO) && defined(ULTRIX_CC20)
217
#define UNWIDENED_PROTOTYPES
220
#define UNWIDENED_PROTOTYPES
223
#ifndef UNWIDENED_PROTOTYPES
224
# if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(THINK_C)
225
# define WIDENED_PROTOTYPES
230
/* The problem below is still the case through 4.0.5F, but the suggested
231
* compiler flags in the Makefiles suppress the nasty messages, so we don't
232
* need to be quite so drastic.
234
#if defined(__sgi) && !defined(__GNUC__)
236
* As of IRIX 4.0.1, /bin/cc claims to be an ANSI compiler, but it thinks
237
* it's impossible for a prototype to match an old-style definition with
238
* unwidened argument types. Thus, we have to turn off all NetHack
239
* prototypes, and avoid declaring several system functions, since the system
240
* include files have prototypes and the compiler also complains that
241
* prototyped and unprototyped declarations don't match.
246
# define NDECL(f) f()
247
# define FDECL(f,p) f()
248
# define VDECL(f,p) f()
253
/* MetaWare High-C defaults to unsigned chars */
254
/* AIX 3.2 needs this also */
255
#if defined(__HC__) || defined(_AIX32)
261
* Allow gcc2 to check parameters of printf-like calls with -Wformat;
262
* append this to a prototype declaration (see pline() in extern.h).
266
#define PRINTF_F(f,v) __attribute__ ((format (printf, f, v)))
270
#define PRINTF_F(f,v)
273
#endif /* TRADSTDC_H */