diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-05-18 14:30:45 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-05-18 14:34:13 +0100 |
commit | 3ba6e1f523ade2e4cc298ace54211a3596ef7ff1 (patch) | |
tree | 4197dccfbf50f63fa1a0f3501986da4b0da79348 | |
parent | e54d4225e2d16d2b5cc928294009fce0a5b30718 (diff) | |
download | mupdf-3ba6e1f523ade2e4cc298ace54211a3596ef7ff1.tar.xz |
Update fitz.h with __cplusplus guard to protect against inline changes.
When including fitz.h from C++ files, we must not alter the definition
of inline, as it may upset code that follows it. We only alter the
definition to enable it if it's available, and it's always available
in C++ - so simply avoiding changing it in the C++ case gives us what
we want.
-rw-r--r-- | fitz/fitz.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 61f80756..10dce6c9 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -92,17 +92,32 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); /* Variadic macros, inline and restrict keywords + + inline is standard in C++, so don't touch the definition in this case. + For some compilers we can enable it within C too. */ +#ifndef __cplusplus #if __STDC_VERSION__ == 199901L /* C99 */ #elif _MSC_VER >= 1500 /* MSVC 9 or newer */ #define inline __inline -#define restrict __restrict #elif __GNUC__ >= 3 /* GCC 3 or newer */ #define inline __inline -#define restrict __restrict #else /* Unknown or ancient */ #define inline +#endif +#endif + +/* + restrict is standard in C99, but not in all C++ compilers. Enable + where possible, disable if in doubt. + */ +#if __STDC_VERSION__ == 199901L /* C99 */ +#elif _MSC_VER >= 1500 /* MSVC 9 or newer */ +#define restrict __restrict +#elif __GNUC__ >= 3 /* GCC 3 or newer */ +#define restrict __restrict +#else /* Unknown or ancient */ #define restrict #endif |