diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-02-06 12:55:12 +0100 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-02-06 13:27:45 +0100 |
commit | a6cbde55a4bc8095556d5b0e134e51d7ac946805 (patch) | |
tree | 142866991a7766e0bbf5082ee2aedcd88d94bfe0 /source | |
parent | f95c4e9ca03417427f76ab9529767734cefab2ff (diff) | |
download | mupdf-a6cbde55a4bc8095556d5b0e134e51d7ac946805.tar.xz |
Workaround for Android: include limits.h where SIZE_MAX is used.
SIZE_MAX is surprisingly supposed to be in stdint.h, but Android
headers for API levels < 21 accidentally put SIZE_MAX in limits.h.
Headers for API levels >= 21 correctly moved SIZE_MAX to stdint.h.
This is the situation for Android NDK r14 and earlier.
Android NDK r15 and later implement a header unification strategy:
all sets of headers for each API level are combined into a single
set of headers covering all API levels. Any differences are
expressed by #ifdeffing on __ANDROID_API__. When this was done
the moving of SIZE_MAX from limits.h to stdint.h was kept and,
importantly, no #ifdefs were used in limits.h/stdint.h concerning
SIZE_MAX. This means that the move of SIZE_MAX was retroactively
introduced for API levels < 21 in Android NDK r15 and later.
For this reason whenever mupdf uses SIZE_MAX it must include both:
* stdint.h (not just in order to follow the POSIX specification,
but also to compile successfully using Android NDK r15 and later)
* and limits.h (in order to compile successfully using Android NDK
r14 and earlier)
Hence these need to include both stdint.h and limits.h, because:
* source/fitz/memory.c uses SIZE_MAX
* source/fitz/store.c uses SIZE_MAX
The mupdf header include/mupdf/fitz/system.h includes stdint.h so
any file that includes system.h will automatically have stdint.h
This is true for both files. limits.h on the other hand needs to
be explicitly included by whomever uses SIZE_MAX. This was already
done by source/fitz/store.c but not by source/fitz/memory.c, but
has now been added.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/memory.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/source/fitz/memory.c b/source/fitz/memory.c index dc085bec..1643647d 100644 --- a/source/fitz/memory.c +++ b/source/fitz/memory.c @@ -1,6 +1,7 @@ #include "mupdf/fitz.h" #include "fitz-imp.h" +#include <limits.h> #include <string.h> #include <stdlib.h> #include <stdio.h> |