Fix problem with 'boolean' definition from IJG JPEG 9.

This commit is contained in:
Bob Friesenhahn 2015-08-16 20:08:21 +00:00
parent 4199a92ce7
commit a0e1185771

View File

@ -1,4 +1,4 @@
/* $Id: raw_decode.c,v 1.6 2015-06-20 16:52:25 bfriesen Exp $ */ /* $Id: raw_decode.c,v 1.7 2015-08-16 20:08:21 bfriesen Exp $ */
/* /*
* Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com> * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com>
@ -41,12 +41,36 @@
#endif #endif
#include "tiffio.h" #include "tiffio.h"
/* /*
Avoid conflicting typedefs for INT32 and boolean when including jpeglib.h. Libjpeg's jmorecfg.h defines INT16 and INT32, but only if XMD_H is
not defined. Unfortunately, the MinGW and Borland compilers include
a typedef for INT32, which causes a conflict. MSVC does not include
a conficting typedef given the headers which are included.
*/ */
#if defined(__MINGW32__) #if defined(__BORLANDC__) || defined(__MINGW32__)
# define XMD_H 1 # define XMD_H 1
# define HAVE_BOOLEAN /* Needs to match statement in jconfig.h */ #endif
/*
The windows RPCNDR.H file defines boolean, but defines it with the
unsigned char size. You should compile JPEG library using appropriate
definitions in jconfig.h header, but many users compile library in wrong
way. That causes errors of the following type:
"JPEGLib: JPEG parameter struct mismatch: library thinks size is 432,
caller expects 464"
For such users we wil fix the problem here. See install.doc file from
the JPEG library distribution for details.
*/
/* Define "boolean" as unsigned char, not int, per Windows custom. */
#if defined(__WIN32__) && !defined(__MINGW32__)
# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean;
# endif
# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif #endif
#include "jpeglib.h" /* Needed for JPEG_LIB_VERSION */ #include "jpeglib.h" /* Needed for JPEG_LIB_VERSION */