emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Revision 110444 breaks the native MS-Windows build


From: Daniel Colascione
Subject: Re: Revision 110444 breaks the native MS-Windows build
Date: Mon, 08 Oct 2012 03:20:12 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

On 10/8/2012 2:03 AM, Eli Zaretskii wrote:
>   #if defined (HAVE_NTGUI) && !defined (WINDOWSNT)

Thanks.

> and in jconfig.h, a jpeglib header included by jpeglib.h, I see this:
> 
>   #ifdef _WIN32
>   # include <windows.h>
>   /* Define "boolean" as unsigned char, not int, per Windows custom */
>   # if !defined __RPCNDR_H__ || defined __MINGW32__    /* don't conflict if 
> rpcndr.h already read */
>   #  ifndef boolean     /* don't conflict if rpcndr.h already read */
>       typedef unsigned char boolean;
>   #  endif /* boolean */
>   # endif /* __RPCNDR_H__ */
>   # define HAVE_BOOLEAN     /* prevent jmorecfg.h from redefining it */
>   # define USE_WINDOWS_MESSAGEBOX 1
>   #endif /* _WIN32 */
> 
> This seems to be in perfect order, so I don't understand the conflict
> you were seeing.
> 
> In any case, you cannot hope for the above to compile unless you also
> typedef jpeg_boolean.

My jpeglib doesn't have that code.  The redefinition actually works fine under
Cygwin --- the jpeglib headers there just define a type they call "boolean",
which, thanks to our preprocessor macro, is substituted with jpeg_boolean.
Presumably, my hack breaks native Windows because there jpeglib _doesn't_ define
boolean.

I tried replacing my hack with the approach below. It does _not_ work ---
although this patch allows Emacs to compile under both Cygwin and native
Windows, it doesn't result in successful JPEG loading under Cygwin, presumably
due to the ABI we've made the jpeglib headers declare no longer matching the
compiled libjpeg we're using.

+/* rpcndr.h and jpeglib.h both define boolean types.  In certain
+   configurations, jpeglib won't detect that rpcndr.h has already
+   defined a boolean type and will instead try to define its own
+   conflicting type.
+
+   At this point, we know we've included windows.h and with it
+   rpcndr.h.  First, include the jpeglib configuration file: if
+   jpeglib thinks the system doesn't have a boolean type, correct this
+   misconception before including the rest of jpeglib.
+
+   */
+#include <jconfig.h>
+#ifndef HAVE_BOOLEAN
+#define HAVE_BOOLEAN 1
+#endif
 #include <jpeglib.h>
 #include <jerror.h>

Instead, let's do this:

+/* rpcndr.h (via windows.h) and jpeglib.h both define boolean types.
+   Some versions of jpeglib try to detect whether rpcndr.h is loaded,
+   using the Windows boolean type instead of the jpeglib boolean type
+   if so.  Cygwin jpeglib, however, doesn't try to detect whether its
+   headers are included along with windows.h, so under Cygwin, jpeglib
+   attempts to define a conflicting boolean type.  Worse, forcing
+   Cygwin jpeglib headers to use the Windows boolean type doesn't work
+   because it created an ABI incompatibility between the
+   already-compiled jpeg library and the header interface definition.
+
+   The best we can do is to define jpeglib's boolean type to a
+   different name.  This name, jpeg_boolean, remains in effect through
+   the rest of image.c.
+*/
+#if defined (CYGWIN) && defined (HAVE_NTGUI)
 #define boolean jpeg_boolean
+#endif
 #include <jpeglib.h>
 #include <jerror.h>


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]