#50 pngcrush 1.7.37 compilation error with mingw 3.20 gcc 4.7.0

None
closed
nobody
None
1
2013-02-02
2012-09-21
pennybag2003
No

Since there aren't any recent binaries available here I thought I'd try compiling pngcrush on my own. I'm using the latest version of mingw (3.20) which uses gcc 4.7.0. When I try to compile using the provided makefile, I get the following error:

In file included from adler32.c:8:0:
zutil.h:33:17: error: conflicting types for 'ptrdiff_t'
In file included from zconf.h:429:0,
from zlib.h:34,
from zutil.h:22,
from adler32.c:8:
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/stddef.h:150:26: note: previous declaration of 'ptrdiff_t' was here
Makefile:66: recipe for target 'adler32.o' failed
mingw32-make: *** [adler32.o] Error 1

It looked like the problem was that zutil.h was trying to define ptrdiff_t when it had already been defined in stddef.h. I commented out the typedefs for ptrdiff_t in zutil.h and was able to compile successfully. The binary I generated seems to be working just fine. A better fix would probably be using #ifndef to check for the symbols that mingw and gcc use. I think they're

_PTRDIFF_T
_T_PTRDIFF_
_T_PTRDIFF
__PTRDIFF_T
_PTRDIFF_T_
_BSD_PTRDIFF_T_
___int_ptrdiff_t_h
_GCC_PTRDIFF_T

And boy howdy markdown is a pain to use, or maybe I'm just not used to it.

I'm not very familiar with git, otherwise I would have just made the change myself and skipped making this ticket. Maybe I should go learn git and do that.

Discussion

  • Forwarded to the zlib maintainers.

     
    • status: open --> accepted
    • milestone: -->
     
    • status: accepted --> closed
     
  • Fixed the bundled zutil.c in pngcrush-1.7.42.