Commit caf5e39c2e68553101519fb4ce3664a73032d3a3
1 parent
6884ad2e
Fix compiler warnings for clang/mac OS X
Showing
5 changed files
with
31 additions
and
25 deletions
libqpdf/Pl_DCT.cc
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | #include <setjmp.h> |
| 5 | 5 | #include <string> |
| 6 | 6 | #include <stdexcept> |
| 7 | +#include <cstdlib> | |
| 7 | 8 | |
| 8 | 9 | #if BITS_IN_JSAMPLE != 8 |
| 9 | 10 | # error "qpdf does not support libjpeg built with BITS_IN_JSAMPLE != 8" |
| ... | ... | @@ -112,17 +113,15 @@ Pl_DCT::compress(void* cinfo_p, PointerHolder<Buffer> b) |
| 112 | 113 | struct jpeg_compress_struct* cinfo = |
| 113 | 114 | reinterpret_cast<jpeg_compress_struct*>(cinfo_p); |
| 114 | 115 | |
| 115 | -#ifdef __GNUC__ | |
| 116 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 116 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 117 | + defined(__clang__)) | |
| 117 | 118 | # pragma GCC diagnostic push |
| 118 | 119 | # pragma GCC diagnostic ignored "-Wold-style-cast" |
| 119 | -# endif | |
| 120 | 120 | #endif |
| 121 | 121 | jpeg_create_compress(cinfo); |
| 122 | -#ifdef __GNUC__ | |
| 123 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 122 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 123 | + defined(__clang__)) | |
| 124 | 124 | # pragma GCC diagnostic pop |
| 125 | -# endif | |
| 126 | 125 | #endif |
| 127 | 126 | unsigned char* outbuffer = 0; |
| 128 | 127 | unsigned long outsize = 0; |
| ... | ... | @@ -171,17 +170,15 @@ Pl_DCT::decompress(void* cinfo_p, PointerHolder<Buffer> b) |
| 171 | 170 | struct jpeg_decompress_struct* cinfo = |
| 172 | 171 | reinterpret_cast<jpeg_decompress_struct*>(cinfo_p); |
| 173 | 172 | |
| 174 | -#ifdef __GNUC__ | |
| 175 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 173 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 174 | + defined(__clang__)) | |
| 176 | 175 | # pragma GCC diagnostic push |
| 177 | 176 | # pragma GCC diagnostic ignored "-Wold-style-cast" |
| 178 | -# endif | |
| 179 | 177 | #endif |
| 180 | 178 | jpeg_create_decompress(cinfo); |
| 181 | -#ifdef __GNUC__ | |
| 182 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 179 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 180 | + defined(__clang__)) | |
| 183 | 181 | # pragma GCC diagnostic pop |
| 184 | -# endif | |
| 185 | 182 | #endif |
| 186 | 183 | jpeg_mem_src(cinfo, b->getBuffer(), b->getSize()); |
| 187 | 184 | ... | ... |
libqpdf/Pl_Flate.cc
| ... | ... | @@ -76,11 +76,10 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush) |
| 76 | 76 | |
| 77 | 77 | // deflateInit and inflateInit are macros that use old-style |
| 78 | 78 | // casts. |
| 79 | -#ifdef __GNUC__ | |
| 80 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 79 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 80 | + defined(__clang__)) | |
| 81 | 81 | # pragma GCC diagnostic push |
| 82 | 82 | # pragma GCC diagnostic ignored "-Wold-style-cast" |
| 83 | -# endif | |
| 84 | 83 | #endif |
| 85 | 84 | if (this->action == a_deflate) |
| 86 | 85 | { |
| ... | ... | @@ -90,10 +89,9 @@ Pl_Flate::handleData(unsigned char* data, int len, int flush) |
| 90 | 89 | { |
| 91 | 90 | err = inflateInit(&zstream); |
| 92 | 91 | } |
| 93 | -#ifdef __GNUC__ | |
| 94 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 92 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 93 | + defined(__clang__)) | |
| 95 | 94 | # pragma GCC diagnostic pop |
| 96 | -# endif | |
| 97 | 95 | #endif |
| 98 | 96 | |
| 99 | 97 | checkError("Init", err); | ... | ... |
libqpdf/SecureRandomDataProvider.cc
| ... | ... | @@ -48,18 +48,16 @@ class WindowsCryptProvider |
| 48 | 48 | PROV_RSA_FULL, |
| 49 | 49 | 0)) |
| 50 | 50 | { |
| 51 | -#ifdef __GNUC__ | |
| 52 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 51 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 52 | + defined(__clang__)) | |
| 53 | 53 | # pragma GCC diagnostic push |
| 54 | 54 | # pragma GCC diagnostic ignored "-Wold-style-cast" |
| 55 | 55 | # pragma GCC diagnostic ignored "-Wsign-compare" |
| 56 | -# endif | |
| 57 | 56 | #endif |
| 58 | 57 | if (GetLastError() == NTE_BAD_KEYSET) |
| 59 | -#ifdef __GNUC__ | |
| 60 | -# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 | |
| 58 | +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \ | |
| 59 | + defined(__clang__)) | |
| 61 | 60 | # pragma GCC diagnostic pop |
| 62 | -# endif | |
| 63 | 61 | #endif |
| 64 | 62 | { |
| 65 | 63 | if (! CryptAcquireContext(&crypt_prov, | ... | ... |
libqpdf/sph/sph_types.h
| ... | ... | @@ -804,6 +804,11 @@ static inline void sph_enc64be_aligned(void *dst, sph_u64 val); |
| 804 | 804 | |
| 805 | 805 | /* ============== END documentation block for Doxygen ============= */ |
| 806 | 806 | |
| 807 | +#if defined(__clang__) | |
| 808 | +# pragma GCC diagnostic push | |
| 809 | +# pragma GCC diagnostic ignored "-Wold-style-cast" | |
| 810 | +#endif | |
| 811 | + | |
| 807 | 812 | #ifndef DOXYGEN_IGNORE |
| 808 | 813 | |
| 809 | 814 | /* |
| ... | ... | @@ -1971,6 +1976,10 @@ sph_dec64le_aligned(const void *src) |
| 1971 | 1976 | |
| 1972 | 1977 | #endif |
| 1973 | 1978 | |
| 1979 | +#if defined(__clang__) | |
| 1980 | +# pragma GCC diagnostic pop | |
| 1981 | +#endif | |
| 1982 | + | |
| 1974 | 1983 | #endif /* Doxygen excluded block */ |
| 1975 | 1984 | |
| 1976 | 1985 | #endif | ... | ... |
libtests/dct_compress.cc
| ... | ... | @@ -17,11 +17,15 @@ static void usage() |
| 17 | 17 | class Callback: public Pl_DCT::CompressConfig |
| 18 | 18 | { |
| 19 | 19 | public: |
| 20 | + Callback() : | |
| 21 | + called(false) | |
| 22 | + { | |
| 23 | + } | |
| 20 | 24 | virtual ~Callback() |
| 21 | 25 | { |
| 22 | 26 | } |
| 23 | 27 | virtual void apply(jpeg_compress_struct*); |
| 24 | - bool called = false; | |
| 28 | + bool called; | |
| 25 | 29 | }; |
| 26 | 30 | |
| 27 | 31 | void Callback::apply(jpeg_compress_struct*) | ... | ... |