We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4311

Summary: warnings when building against libpng-1.4/1.5
Product: SDL_image Reporter: Ozkan Sezer <sezeroz>
Component: miscAssignee: Ozkan Sezer <sezeroz>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: All   
OS: All   
Attachments: IMG_png warnings patch

Description Ozkan Sezer 2018-10-13 12:20:06 UTC
Created attachment 3371 [details]
IMG_png warnings patch

When building against libpng-1.4/1.5 with --disable-png-shared, warnings
are emitted:
I20/IMG_png.c:145: warning: assignment from incompatible pointer type
I20/IMG_png.c:146: warning: assignment from incompatible pointer type
I20/IMG_png.c:147: warning: assignment from incompatible pointer type
I20/IMG_png.c:148: warning: assignment from incompatible pointer type

Some libpng functions take non-const args in 1.2..1.5, but take const
args in 1.6.  To make it worse, some funcs, e.g. png_get_PLTE(), take
const args in 1.4..1.5 but take non-const args in 1.6+, like:
1.4/1.5: (png_const_structp , png_const_infop, png_colorp *, int *)
1.6/1.7: (png_const_structrp, png_inforp     , png_colorp *, int *)

I came up with the following quick'n'dirty patch, which adds noconst15
and noconst16 to affected function pointer typedefs:
noconst15: version < 1.6 doesn't have const, >= 1.6 adds it
noconst16: version < 1.6 does have const, >= 1.6 removes it

Should I apply, or should we live with the warnings (which would break
builds if one uses -Werror) ?
Comment 1 Ozkan Sezer 2018-10-23 20:01:18 UTC
Went ahead and applied this:
http://hg.libsdl.org/SDL_image/rev/89225c8816d6
http://hg.libsdl.org/SDL_image/rev/fa3c53a205a9