all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Revision 110444 breaks the native MS-Windows build
@ 2012-10-08  8:38 Eli Zaretskii
  2012-10-08  8:40 ` Daniel Colascione
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2012-10-08  8:38 UTC (permalink / raw
  To: Daniel Colascione; +Cc: emacs-devel

Error messages look like this:

  image.c:6081: error: `fn_jpeg_start_decompress' declared as function returning a function
  image.c:6082: error: `fn_jpeg_finish_decompress' declared as function returning a function
  image.c:6087: error: `fn_jpeg_resync_to_restart' declared as function returning a function
  image.c:6112: error: `jpeg_resync_to_restart_wrapper' declared as function returning a function
  image.c:6136: error: field `cinfo' has incomplete type
  image.c: In function `my_error_exit':
  image.c:6152: error: dereferencing pointer to incomplete type
  image.c: At top level:
  image.c:6185: error: `our_memory_fill_input_buffer' declared as function returning a function



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Revision 110444 breaks the native MS-Windows build
  2012-10-08  8:38 Revision 110444 breaks the native MS-Windows build Eli Zaretskii
@ 2012-10-08  8:40 ` Daniel Colascione
  2012-10-08  9:03   ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Colascione @ 2012-10-08  8:40 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

On 10/8/2012 1:38 AM, Eli Zaretskii wrote:
> Error messages look like this:
> 
>   image.c:6081: error: `fn_jpeg_start_decompress' declared as function returning a function
>   image.c:6082: error: `fn_jpeg_finish_decompress' declared as function returning a function
>   image.c:6087: error: `fn_jpeg_resync_to_restart' declared as function returning a function
>   image.c:6112: error: `jpeg_resync_to_restart_wrapper' declared as function returning a function
>   image.c:6136: error: field `cinfo' has incomplete type
>   image.c: In function `my_error_exit':
>   image.c:6152: error: dereferencing pointer to incomplete type
>   image.c: At top level:
>   image.c:6185: error: `our_memory_fill_input_buffer' declared as function returning a function
> 

Crap. That's what I get for testing --without-jpeg, --without-gif, etc. I'll
find the libraries and fix the break.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Revision 110444 breaks the native MS-Windows build
  2012-10-08  8:40 ` Daniel Colascione
@ 2012-10-08  9:03   ` Eli Zaretskii
  2012-10-08  9:20     ` Eli Zaretskii
  2012-10-08 10:20     ` Daniel Colascione
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-10-08  9:03 UTC (permalink / raw
  To: Daniel Colascione; +Cc: emacs-devel

> Date: Mon, 08 Oct 2012 01:40:20 -0700
> From: Daniel Colascione <dancol@dancol.org>
> CC: emacs-devel@gnu.org
> 
> On 10/8/2012 1:38 AM, Eli Zaretskii wrote:
> > Error messages look like this:
> > 
> >   image.c:6081: error: `fn_jpeg_start_decompress' declared as function returning a function
> >   image.c:6082: error: `fn_jpeg_finish_decompress' declared as function returning a function
> >   image.c:6087: error: `fn_jpeg_resync_to_restart' declared as function returning a function
> >   image.c:6112: error: `jpeg_resync_to_restart_wrapper' declared as function returning a function
> >   image.c:6136: error: field `cinfo' has incomplete type
> >   image.c: In function `my_error_exit':
> >   image.c:6152: error: dereferencing pointer to incomplete type
> >   image.c: At top level:
> >   image.c:6185: error: `our_memory_fill_input_buffer' declared as function returning a function
> > 
> 
> Crap. That's what I get for testing --without-jpeg, --without-gif, etc. I'll
> find the libraries and fix the break.

The problems are here:

  #ifdef HAVE_NTGUI
   /* Glue for code below */
   #define fn_XpmReadFileToImage XpmReadFileToImage
   #define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer
   #define fn_XImageFree XImageFree
   #define fn_XpmFreeAttributes XpmFreeAttributes
  #endif /* HAVE_NTGUI */

This is inappropriate for MS-Windows, so I suggest to replace

  #ifdef HAVE_NTGUI

with

  #if defined (HAVE_NTGUI) && !defined (WINDOWSNT)

OK?

The more serious problem is here:
 
 /* Work around conflict between jpeg boolean and rpcndr.h
    under Windows. */
 #define boolean jpeg_boolean   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 #include <jpeglib.h>
 #include <jerror.h>
 
You never explained what kind of conflict did you try to solve.  (I
find the description of changes in image.c inadequate, most of the
changes are simply left out.)  If I ifdef away that marked line,
everything compiles, and the resulting executable is able to display
JPEG images.

What I see in rpcndr.h (its MinGW variant) is this:

  typedef unsigned char boolean;

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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Revision 110444 breaks the native MS-Windows build
  2012-10-08  9:03   ` Eli Zaretskii
@ 2012-10-08  9:20     ` Eli Zaretskii
  2012-10-08 10:20     ` Daniel Colascione
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-10-08  9:20 UTC (permalink / raw
  To: dancol; +Cc: emacs-devel

I committed a temporary change to fix the breakage.  When we have
figured out what's TRT, we can replace that with whatever is right.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Revision 110444 breaks the native MS-Windows build
  2012-10-08  9:03   ` Eli Zaretskii
  2012-10-08  9:20     ` Eli Zaretskii
@ 2012-10-08 10:20     ` Daniel Colascione
  2012-10-08 11:56       ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Colascione @ 2012-10-08 10:20 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3187 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Revision 110444 breaks the native MS-Windows build
  2012-10-08 10:20     ` Daniel Colascione
@ 2012-10-08 11:56       ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2012-10-08 11:56 UTC (permalink / raw
  To: Daniel Colascione; +Cc: emacs-devel

> Date: Mon, 08 Oct 2012 03:20:12 -0700
> From: Daniel Colascione <dancol@dancol.org>
> CC: emacs-devel@gnu.org
> 
> > 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.

Which version of jpeglib is that, and where can I see its full set of
headers?  The latest upstream version, 8d, does seem to 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.

Yes.

> 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.

What type does jpeglib define its 'boolean' to in the Cygwin build you
have?  Or does it use Cygwin's own 'boolean'? if so, what is its width?

FWIW, I've just configured the latest jpeglib for MinGW, and the above
conditional definition did appear in jconfig.h that was created.

In any case, this sounds like a problem someone should report
upstream: a Cygwin application using jpeglib could definitely include
Windows headers, can't it?  If jpeglib configured for Cygwin doesn't
include the above conditional, then it will cause bugs on Cygwin, I
think.

> 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>

That could be fine, but I'd like to understand the problem some more,
because the problem you had could be specific to some version of
jpeglib, and if so, this change could break with other versions or on
other Cygwin installations.

Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-08 11:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08  8:38 Revision 110444 breaks the native MS-Windows build Eli Zaretskii
2012-10-08  8:40 ` Daniel Colascione
2012-10-08  9:03   ` Eli Zaretskii
2012-10-08  9:20     ` Eli Zaretskii
2012-10-08 10:20     ` Daniel Colascione
2012-10-08 11:56       ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.