Source:NetHack 5.0.0/include/lint.h
Jump to navigation
Jump to search
Below is the full text to lint.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/lint.h#line12]], 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 5.0 lint.h $NHDT-Date: 1655631029 2022/06/19 09:30:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.8 $ */ 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. #define nhUse(arg) ((void) (arg)) 19. 20. /* 21. * This stuff isn't related to lint suppression but lives here to 22. * avoid cluttering up hack.h. 23. */ 24. /* [DEBUG shouldn't be defined unless you know what you're doing...] */ 25. #ifdef DEBUG 26. #define showdebug(file) debugcore(file, TRUE) 27. #define explicitdebug(file) debugcore(file, FALSE) 28. /* in case 'stmt' is pline() or something which calls pline(), 29. save and restore previous plnmsg code so that use of debugpline() 30. doesn't change message semantics */ 31. #define ifdebug(stmt) \ 32. do { \ 33. if (showdebug(__FILE__)) { \ 34. int save_plnmsg = iflags.last_msg; \ 35. stmt; \ 36. iflags.last_msg = save_plnmsg; \ 37. } \ 38. } while (0) 39. #ifdef _MSC_VER 40. /* if we have microsoft's C runtime we can use these instead */ 41. #include <crtdbg.h> 42. #define crtdebug(stmt) \ 43. do { \ 44. if (showdebug(__FILE__)) { \ 45. int save_plnmsg = iflags.last_msg; \ 46. stmt; \ 47. iflags.last_msg = save_plnmsg; \ 48. } \ 49. _RPT0(_CRT_WARN, "\n"); \ 50. } while (0) 51. #define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str)) 52. #define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg)) 53. #define debugpline2(fmt, a1, a2) crtdebug(_RPT2(_CRT_WARN, fmt, a1, a2)) 54. #define debugpline3(fmt, a1, a2, a3) \ 55. crtdebug(_RPT3(_CRT_WARN, fmt, a1, a2, a3)) 56. #define debugpline4(fmt, a1, a2, a3, a4) \ 57. crtdebug(_RPT4(_CRT_WARN, fmt, a1, a2, a3, a4)) 58. #else 59. /* these don't require compiler support for C99 variadic macros */ 60. #define debugpline0(str) ifdebug(pline(str)) 61. #define debugpline1(fmt, arg) ifdebug(pline(fmt, arg)) 62. #define debugpline2(fmt, a1, a2) ifdebug(pline(fmt, a1, a2)) 63. #define debugpline3(fmt, a1, a2, a3) ifdebug(pline(fmt, a1, a2, a3)) 64. #define debugpline4(fmt, a1, a2, a3, a4) ifdebug(pline(fmt, a1, a2, a3, a4)) 65. #endif 66. #else 67. #define debugpline0(str) /*empty*/ 68. #define debugpline1(fmt, arg) /*empty*/ 69. #define debugpline2(fmt, a1, a2) /*empty*/ 70. #define debugpline3(fmt, a1, a2, a3) /*empty*/ 71. #define debugpline4(fmt, a1, a2, a3, a4) /*empty*/ 72. #endif /*DEBUG*/ 73. 74. #endif /* LINT_H */