1 /* NetHack 3.6 lint.h $NHDT-Date: 1524689514 2018/04/25 20:51:54 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.5 $ */
2 /* Copyright (c) 2016 by Robert Patrick Rankin */
3 /* NetHack may be freely redistributed. See license for details. */
6 * Hacks to suppress compiler warnings. Use with caution.
7 * Assumes it has been preceded by '#include "config.h"' but
8 * not necessarily by '#include "hack.h"'.
13 /* cast away implicit const from a string literal (caller's responsibility
14 to ensure that) in order to avoid a warning from 'gcc -Wwrite-strings'
15 (also caller's responsibility to ensure it isn't actually modified!) */
16 #define nhStr(str) ((char *) str)
18 #if defined(GCC_WARN) && !defined(FORCE_ARG_USAGE)
19 #define FORCE_ARG_USAGE
22 #ifdef FORCE_ARG_USAGE
23 /* force an unused function argument to become used in an arbitrary
24 manner in order to suppress warning about unused function arguments;
25 viable for scalar and pointer arguments */
26 #define nhUse(arg) nhUse_dummy += (unsigned) !(arg)
27 extern unsigned nhUse_dummy;
29 #define nhUse(arg) /*empty*/
33 * This stuff isn't related to lint suppression but lives here to
34 * avoid cluttering up hack.h.
36 /* [DEBUG shouldn't be defined unless you know what you're doing...] */
38 #define showdebug(file) debugcore(file, TRUE)
39 #define explicitdebug(file) debugcore(file, FALSE)
40 #define ifdebug(stmt) \
42 if (showdebug(__FILE__)) { \
47 /* if we have microsoft's C runtime we can use these instead */
49 #define crtdebug(stmt) \
51 if (showdebug(__FILE__)) { \
54 _RPT0(_CRT_WARN, "\n"); \
56 #define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str))
57 #define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg))
58 #define debugpline2(fmt, a1, a2) crtdebug(_RPT2(_CRT_WARN, fmt, a1, a2))
59 #define debugpline3(fmt, a1, a2, a3) \
60 crtdebug(_RPT3(_CRT_WARN, fmt, a1, a2, a3))
61 #define debugpline4(fmt, a1, a2, a3, a4) \
62 crtdebug(_RPT4(_CRT_WARN, fmt, a1, a2, a3, a4))
64 /* these don't require compiler support for C99 variadic macros */
65 #define debugpline0(str) ifdebug(pline(str))
66 #define debugpline1(fmt, arg) ifdebug(pline(fmt, arg))
67 #define debugpline2(fmt, a1, a2) ifdebug(pline(fmt, a1, a2))
68 #define debugpline3(fmt, a1, a2, a3) ifdebug(pline(fmt, a1, a2, a3))
69 #define debugpline4(fmt, a1, a2, a3, a4) ifdebug(pline(fmt, a1, a2, a3, a4))
72 #define debugpline0(str) /*empty*/
73 #define debugpline1(fmt, arg) /*empty*/
74 #define debugpline2(fmt, a1, a2) /*empty*/
75 #define debugpline3(fmt, a1, a2, a3) /*empty*/
76 #define debugpline4(fmt, a1, a2, a3, a4) /*empty*/
81 #define PRAGMA_IGNORE_HELPER0(x) #x
82 #define PRAGMA_IGNORE_HELPER1(x) PRAGMA_IGNORE_HELPER0(GCC diagnostic ignored x)
83 #define PRAGMA_IGNORE_HELPER2(y) PRAGMA_IGNORE_HELPER1(#y)
84 #define _pragma_ignore(opt) _Pragma("GCC diagnostic push") \
85 _Pragma(PRAGMA_IGNORE_HELPER2(opt))
86 #define _pragma_pop _Pragma("GCC diagnostic pop")
89 #define _pragma_ignore(opt)