doesn't include <stdio.h> before <jpeglib.h>
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libmng (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
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://
"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/
/usr/include/
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
/usr/include/
EXTERN(void) jpeg_stdio_src JPP((j_
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:/
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(
#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(
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:/
description: | updated |
Status changed to 'Confirmed' because the bug affects multiple users.