diff options
| author | Simon Tatham <anakin@pobox.com> | 2023-04-06 07:07:30 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2023-04-06 07:08:04 +0100 |
| commit | 3b9cafa09f783ccadda14d11fc8b73dc496368c0 (patch) | |
| tree | 8bb6f035ca4d76d77b5f81436f6651dc0a9b21ea | |
| parent | d9355041a55f281436c59fecaac1e15e4c585f8d (diff) | |
| download | puzzles-3b9cafa09f783ccadda14d11fc8b73dc496368c0.zip puzzles-3b9cafa09f783ccadda14d11fc8b73dc496368c0.tar.gz puzzles-3b9cafa09f783ccadda14d11fc8b73dc496368c0.tar.bz2 puzzles-3b9cafa09f783ccadda14d11fc8b73dc496368c0.tar.xz | |
Fall back to <math.h> if <tgmath.h> doesn't work.
This fixes a build failure introduced by commit 2e48ce132e011e8
yesterday.
When I saw that commit I expected the most likely problem would be in
the NestedVM build, which is currently the thing with the most most
out-of-date C implementation. And indeed the NestedVM toolchain
doesn't have <tgmath.h> - but much more surprisingly, our _Windows_
builds failed too, with a compile error inside <tgmath.h> itself!
I haven't looked closely into the problem yet. Our Windows builds are
done with clang, which comes with its own <tgmath.h> superseding the
standard Windows one. So you'd _hope_ that clang could make sense of
its own header! But perhaps the problem is that this is an unusual
compile mode and hasn't been tested.
My fix is to simply add a cmake check for <tgmath.h> - which doesn't
just check the file's existence, it actually tries compiling a file
that #includes it, so it will detect 'file exists but is mysteriously
broken' just as easily as 'not there at all'. So this makes the builds
start working again, precisely on Ben's theory of opportunistically
using <tgmath.h> where possible and falling back to <math.h>
otherwise.
It looks ugly, though! I'm half tempted to make a new header file
whose job is to include a standard set of system headers, just so that
that nasty #ifdef doesn't have to sit at the top of almost all the
source files. But for the moment this at least gets the build working
again.
| -rw-r--r-- | auxiliary/hat-test.c | 6 | ||||
| -rw-r--r-- | auxiliary/hatgen.c | 6 | ||||
| -rw-r--r-- | blackbox.c | 6 | ||||
| -rw-r--r-- | bridges.c | 6 | ||||
| -rw-r--r-- | cmake/setup.cmake | 4 | ||||
| -rw-r--r-- | cube.c | 6 | ||||
| -rw-r--r-- | dominosa.c | 6 | ||||
| -rw-r--r-- | drawing.c | 6 | ||||
| -rw-r--r-- | fifteen.c | 6 | ||||
| -rw-r--r-- | filling.c | 6 | ||||
| -rw-r--r-- | flip.c | 6 | ||||
| -rw-r--r-- | flood.c | 6 | ||||
| -rw-r--r-- | galaxies.c | 6 | ||||
| -rw-r--r-- | grid.c | 6 | ||||
| -rw-r--r-- | gtk.c | 6 | ||||
| -rw-r--r-- | guess.c | 6 | ||||
| -rw-r--r-- | hat.c | 6 | ||||
| -rw-r--r-- | inertia.c | 6 | ||||
| -rw-r--r-- | keen.c | 6 | ||||
| -rw-r--r-- | lightup.c | 6 | ||||
| -rw-r--r-- | loopgen.c | 6 | ||||
| -rw-r--r-- | loopy.c | 6 | ||||
| -rw-r--r-- | magnets.c | 6 | ||||
| -rw-r--r-- | map.c | 6 | ||||
| -rw-r--r-- | mines.c | 6 | ||||
| -rw-r--r-- | misc.c | 6 | ||||
| -rw-r--r-- | mosaic.c | 6 | ||||
| -rw-r--r-- | net.c | 6 | ||||
| -rw-r--r-- | netslide.c | 6 | ||||
| -rw-r--r-- | nullgame.c | 6 | ||||
| -rw-r--r-- | pattern.c | 6 | ||||
| -rw-r--r-- | pearl.c | 6 | ||||
| -rw-r--r-- | pegs.c | 6 | ||||
| -rw-r--r-- | penrose.c | 6 | ||||
| -rw-r--r-- | range.c | 6 | ||||
| -rw-r--r-- | rect.c | 6 | ||||
| -rw-r--r-- | samegame.c | 6 | ||||
| -rw-r--r-- | signpost.c | 6 | ||||
| -rw-r--r-- | singles.c | 6 | ||||
| -rw-r--r-- | sixteen.c | 6 | ||||
| -rw-r--r-- | slant.c | 6 | ||||
| -rw-r--r-- | solo.c | 6 | ||||
| -rw-r--r-- | tents.c | 6 | ||||
| -rw-r--r-- | towers.c | 6 | ||||
| -rw-r--r-- | tracks.c | 6 | ||||
| -rw-r--r-- | twiddle.c | 6 | ||||
| -rw-r--r-- | undead.c | 6 | ||||
| -rw-r--r-- | unequal.c | 6 | ||||
| -rw-r--r-- | unfinished/group.c | 6 | ||||
| -rw-r--r-- | unfinished/numgame.c | 6 | ||||
| -rw-r--r-- | unfinished/separate.c | 6 | ||||
| -rw-r--r-- | unfinished/slide.c | 6 | ||||
| -rw-r--r-- | unfinished/sokoban.c | 6 | ||||
| -rw-r--r-- | unruly.c | 6 | ||||
| -rw-r--r-- | untangle.c | 6 |
55 files changed, 274 insertions, 54 deletions
diff --git a/auxiliary/hat-test.c b/auxiliary/hat-test.c index 4f8dc65..254d82c 100644 --- a/auxiliary/hat-test.c +++ b/auxiliary/hat-test.c @@ -5,7 +5,11 @@ */ #include <assert.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdarg.h> #include <stdio.h> #include <string.h> diff --git a/auxiliary/hatgen.c b/auxiliary/hatgen.c index 9574cb8..30242c9 100644 --- a/auxiliary/hatgen.c +++ b/auxiliary/hatgen.c @@ -16,7 +16,11 @@ */ #include <assert.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -7,7 +7,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -73,7 +73,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" diff --git a/cmake/setup.cmake b/cmake/setup.cmake index 0a710b6..3c91285 100644 --- a/cmake/setup.cmake +++ b/cmake/setup.cmake @@ -47,6 +47,10 @@ check_include_file(stdint.h HAVE_STDINT_H) if(NOT HAVE_STDINT_H) add_compile_definitions(NO_STDINT_H) endif() +check_include_file(tgmath.h HAVE_TGMATH_H) +if(NOT HAVE_TGMATH_H) + add_compile_definitions(NO_TGMATH_H) +endif() # Try to normalise source file pathnames as seen in __FILE__ (e.g. # assertion failure messages). Partly to avoid bloating the binaries @@ -7,7 +7,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -48,7 +48,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -27,7 +27,11 @@ #include <stdlib.h> #include <string.h> #include <assert.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -8,7 +8,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -58,7 +58,11 @@ #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -9,7 +9,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -32,7 +32,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -80,7 +80,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -13,7 +13,11 @@ #include <ctype.h> #include <float.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -13,7 +13,11 @@ #include <stdarg.h> #include <string.h> #include <errno.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <unistd.h> #include <sys/time.h> @@ -7,7 +7,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -12,7 +12,11 @@ */ #include <assert.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -12,7 +12,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -8,7 +8,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "latin.h" @@ -48,7 +48,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -8,7 +8,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -77,7 +77,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -37,7 +37,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -15,7 +15,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -13,7 +13,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "tree234.h" #include "puzzles.h" @@ -3,7 +3,11 @@ */ #include <assert.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -14,7 +14,11 @@ #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -8,7 +8,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -9,7 +9,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -16,7 +16,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -8,7 +8,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -36,7 +36,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "grid.h" @@ -8,7 +8,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" @@ -9,7 +9,11 @@ #include <assert.h> #include <string.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include <stdio.h> #include "puzzles.h" /* for malloc routines, and PI */ @@ -58,7 +58,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -26,7 +26,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -68,7 +68,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -8,7 +8,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -58,7 +58,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "latin.h" @@ -10,7 +10,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -28,7 +28,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -87,7 +87,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #ifdef STANDALONE_SOLVER #include <stdarg.h> @@ -33,7 +33,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "matching.h" @@ -23,7 +23,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "latin.h" @@ -21,7 +21,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -11,7 +11,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -35,7 +35,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -21,7 +21,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "latin.h" /* contains typedef for digit */ diff --git a/unfinished/group.c b/unfinished/group.c index 345deb5..bbac220 100644 --- a/unfinished/group.c +++ b/unfinished/group.c @@ -31,7 +31,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "latin.h" diff --git a/unfinished/numgame.c b/unfinished/numgame.c index 5de69a2..cf91992 100644 --- a/unfinished/numgame.c +++ b/unfinished/numgame.c @@ -40,7 +40,11 @@ #include <string.h> #include <limits.h> #include <assert.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" diff --git a/unfinished/separate.c b/unfinished/separate.c index fdeeb3d..d3423de 100644 --- a/unfinished/separate.c +++ b/unfinished/separate.c @@ -94,7 +94,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" diff --git a/unfinished/slide.c b/unfinished/slide.c index a4cf168..115230f 100644 --- a/unfinished/slide.c +++ b/unfinished/slide.c @@ -32,7 +32,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" diff --git a/unfinished/sokoban.c b/unfinished/sokoban.c index a493bf4..bef7d72 100644 --- a/unfinished/sokoban.c +++ b/unfinished/sokoban.c @@ -58,7 +58,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -47,7 +47,11 @@ #include <string.h> #include <assert.h> #include <ctype.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" @@ -32,7 +32,11 @@ #include <assert.h> #include <ctype.h> #include <limits.h> -#include <tgmath.h> +#ifdef NO_TGMATH_H +# include <math.h> +#else +# include <tgmath.h> +#endif #include "puzzles.h" #include "tree234.h" |