desktop-packages team mailing list archive
-
desktop-packages team
-
Mailing list archive
-
Message #95772
[Bug 1342459] Re: doesn't include <stdio.h> before <jpeglib.h>
Status changed to 'Confirmed' because the bug affects multiple users.
** Changed in: libmng (Ubuntu)
Status: New => Confirmed
--
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to libmng in Ubuntu.
https://bugs.launchpad.net/bugs/1342459
Title:
doesn't include <stdio.h> before <jpeglib.h>
Status in libmng package in Ubuntu:
Confirmed
Bug description:
libmng 2.0.2-0ubuntu3 in Ubuntu 14.04 (trusty), gcc 4.8.
tldr summary: libmng_types.h should #include <stdio.h> before
<jpeglib.h>. Could also check for HAVE_BOOLEAN being defined before
defining it.
details:
http://www.freedesktop.org/wiki/Software/libjpeg/
"Applications using the JPEG library should include the header file
jpeglib.h to obtain declarations of data types and routines. Before
including jpeglib.h, include system headers that define at least the
typedefs FILE and size_t."
So libjpeg is a special snowflake and doesn't #include the necessary
headers to define all the types it mentions. Presumably this is for
small footprint things that don't need the stdio parts of libjpeg, and
can hack something up to make it compile without pulling in <stdio.h>.
libmng 2.0.2 doesn't do this, so this won't compile:
#include <libmng.h>
int main() { return 0; }
In file included from /usr/include/libmng_types.h:203:0,
from /usr/include/libmng.h:386,
from mng-inc.c:1:
/usr/include/jpeglib.h:1000:30: error: unknown type name ‘FILE’
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
^
/usr/include/jpeglib.h:1001:29: error: unknown type name ‘FILE’
EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
This breaks autoconf detection of libmng when compiling mplayer from
source, for example.
The obvious fix is for libmng_types.h to #include <stdio.h> right
before jpeglib.h.
If cleaning up the headers anyway, the typedef int boolean;
apparently caused a problem for someone when compiling the GIMP with
some version of jpeglib, as it includes jpeglib.h before libmng.h.
https://sourceforge.net/p/png-mng/mailman/message/31502284/. (which I
noticed since it showed up on the same page as the message about
mplayer's autoconf test for libmng.)
I had a look: jpeglib checks for but doesn't set HAVE_BOOLEAN, and
libmng sets HAVE_BOOLEAN without checking.
// in jmorecfg.h
#ifndef HAVE_BOOLEAN
typedef int boolean;
#endif
// in libmng_types.h
#ifndef _WIN32
#define HAVE_BOOLEAN
typedef int boolean;
#endif
It's not an error to have multiple identical typedefs, so presumably
the problem happened with a different libjpeg version that defined
boolean to something else. I'm not sure what the point of the logic
is, though. Surely testing on #ifndef HAVE_BOOLEAN would be a good
idea. i.e.
#if !defined(HAVE_BOOLEAN) && !defined(_WIN32)
#define HAVE_BOOLEAN
typedef int boolean;
#endif
I assume the idea is to avoid defining it at all on win32. So I
guess code that wants to compile on win32 depends on jpeglib.h
(included by libmng.h) providing a typedef for boolean, or depends on
having boolean defined by windows stuff. It might make more sense
just to remove defining boolean from libmng_types.h altogether, if it
can do without it and still compile on win32. This could break things
if using libmng.h with a different jpeglib.h that didn't provide a
typedef for boolean, so the safest would be the #if
!defined(HAVE_BOOLEAN) && !defined(_WIN32) check.
Anyway, both of these were reported on the mailing list right after
2.0.2 released, without replies or updates from upstream. And
upstream's sourceforge ticket tracker
(https://sourceforge.net/p/libmng/bugs/) doesn't allow ticket
creation. So I'm reporting it here instead of trying to chase down
upstream maintainers myself.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libmng/+bug/1342459/+subscriptions