onefile: isaac64.c <math.h> vs yn()

isaac64.c includes <math.h>.  yn() is a non-STDC math function in
<math.h> and that conflicts with nethack's yn() macro or vice versa.

If other source files begin using <math.h> this will probably need
to be handled differently.
This commit is contained in:
PatR
2022-09-13 13:59:24 -07:00
parent bac60d21a5
commit 94945a719a

View File

@@ -7,11 +7,25 @@
* Changes for NetHack:
* include config.h;
* skip rest of file if USE_ISAAC64 isn't defined there;
* yn() hackery;
* re-do 'inline' handling.
*/
#include "config.h"
#ifdef USE_ISAAC64
/*
* OSX <math.h> declares yn() in a section labelled
* "POSIX/UNIX extensions to the C standard".
*
* Even when yn() is not a macro, expansion of nethack's yn() macro
* would break it. Matters for 'onefile' lint checking where contents
* of hack.h will be visible even though we only include config.h.
*/
#ifdef yn
#undef yn
#define _isaac64_hide_yn
#endif
#include <math.h>
#include <string.h>
#include "isaac64.h"
@@ -171,6 +185,17 @@ uint64_t isaac64_next_uint(isaac64_ctx *_ctx,uint64_t _n){
while(((d+_n-1)&ISAAC64_MASK)<d);
return v;
}
#ifdef _isaac64_hide_yn
/* 'onefile' support; restore nethack's yn() macro;
this could be made more robust but doesn't need that */
#ifdef yn
#undef yn /* in case <math.h> defines yn() as a macro */
#endif
#define yn(query) yn_function(query, ynchars, 'n', TRUE)
#undef _isaac64_hide_yn
#endif
#endif /* USE_ISAAC64 */
/*isaac64.c*/