Source:NetHack 3.6.1/include/lint.h

From NetHackWiki
(Redirected from Source:Lint.h)
Jump to: navigation, search

Below is the full text to lint.h from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/include/lint.h#line123]], for example.

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.  /* 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. */
  4.  
  5.  /*
  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"'.
  9.   */
  10.  #ifndef LINT_H
  11.  #define LINT_H
  12.  
  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)
  17.  
  18.  #if defined(GCC_WARN) && !defined(FORCE_ARG_USAGE)
  19.  #define FORCE_ARG_USAGE
  20.  #endif
  21.  
  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;
  28.  #else
  29.  #define nhUse(arg) /*empty*/
  30.  #endif
  31.  
  32.  /*
  33.   * This stuff isn't related to lint suppression but lives here to
  34.   * avoid cluttering up hack.h.
  35.   */
  36.  /* [DEBUG shouldn't be defined unless you know what you're doing...] */
  37.  #ifdef DEBUG
  38.  #define showdebug(file) debugcore(file, TRUE)
  39.  #define explicitdebug(file) debugcore(file, FALSE)
  40.  #define ifdebug(stmt)                   \
  41.      do {                                \
  42.          if (showdebug(__FILE__)) {      \
  43.              stmt;                       \
  44.          }                               \
  45.      } while (0)
  46.  #ifdef _MSC_VER
  47.  /* if we have microsoft's C runtime we can use these instead */
  48.  #include <crtdbg.h>
  49.  #define crtdebug(stmt)                  \
  50.      do {                                \
  51.          if (showdebug(__FILE__)) {      \
  52.              stmt;                       \
  53.          }                               \
  54.          _RPT0(_CRT_WARN, "\n");         \
  55.      } while (0)
  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))
  63.  #else
  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))
  70.  #endif
  71.  #else
  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*/
  77.  #endif                                   /*DEBUG*/
  78.  
  79.  #endif /* LINT_H */