In png.h, there are various functions, like png_handle_as_unknown
and png_get_pixels_per_inch declared without the "extern" keyword,
most are defined using "extern". This is causing a problem for me,
because in tkImg I would like to define PNG_IMPEXP as
MODULE_SCOPE (which is already handled by Tcl/Tk), but
this macro already has the "extern" in it.
Because the "extern" keyword serves no purpose, I
would like to request to search and replace
"extern PNG_EXPORT" with "PNG_EXPORT"
everywhere in png.h. Patch attached.
proposed fix
Thanks. There are also several instances of "extern" in pngpriv.h
Those should probably be PNG_EXTERN.
I have passed your bug report to the png-mng-implement mailing
list for discussion.
Glenn
The change has been implemented in libpng-1.5.0beta33
Glenn
Sure, and it would be nice to be able to define PNG_EXTERN from
the outsize as "extern __attribute__((__visibility__("hidden\")))", so
it can be hidden from the library completely (assuming gcc)
Here is the follow-up patch to pngpriv.h
patch to pngpriv.h
Both fixes are in libpng-1.5.0beta34 and 1.4.4beta01.
TkImg upgraded libpng to version 1.6.17, and the same problem cropped up again: When defining PNG_EXTERN being equal to Tcl/Tk's MODULE_EXPORT, this results in a duplicated "extern" token.
Proposed patch, which fixes this problem, is attached.
Applying the patch to libpng-1.6.18beta08 caused a large number of warnings. I moved the definition of PNG_EXPORTA below the definition of PNG_EMPTY and then changed "extern attributes" instead to "PNG_EMPTY attributes". That worked for me on Ubuntu with gcc-4.8.2. Revised patch is attached (deleted because it introduced an API incompatibility, see below for replacement patch).
Last edit: Glenn Randers-Pehrson 2015-07-03
Jan, What version of libpng were you updating to 1.6.17? We'd like to determine when the problem reappeared and why. Note that there's no PNG_EXTERN in libpng-1.6!
We upgraded from 1.4.12 directly to 1.6.17, So I guess the change was with 1.5.0 or 1.6.0
Revised the patch to avoid introducing an API incompatibility.
Here is a more complete patch by John Bowler. Please give it a try.
With the last patch, I'm still getting:
In file included from ./../compat/libpng/pngpriv.h:293:0,
from ./../compat/libpng/png.c:14:
./../compat/libpng/png.h:1043:1: error: duplicate ‘extern’
PNG_EXPORT(1, png_uint_32, png_access_version_number, (void));
^
./../compat/libpng/png.h:1048:1: error: duplicate ‘extern’
PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
^
./../compat/libpng/png.h:1055:1: error: duplicate ‘extern’
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,
^
The other two earlier patches worked fine (at least everything compiles, I didn't check if the symbol exports were really surpressed, that what's the intention)
Assuming you did
-DPNG_LINKAGE_API=
or similar. Otherwise the "extern" will still appear.
Closing as fixed. Reopen if you're still experiencing this bug.