Source:NetHack 3.4.3/include/tradstdc.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to include/tradstdc.h from NetHack 3.4.3. To link to a particular line, write [[tradstdc.h#line123]], for example.

  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. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

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