From 3ba6e1f523ade2e4cc298ace54211a3596ef7ff1 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 18 May 2012 14:30:45 +0100 Subject: 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. --- fitz/fitz.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'fitz') 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 -- cgit v1.2.3