Menu

#159 Consistant use of "extern" in png.h

libpng_code
closed-fixed
5
2015-11-20
2010-07-06
No

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.

Discussion

  • Jan Nijtmans

    Jan Nijtmans - 2010-07-06

    proposed fix

     
  • Glenn Randers-Pehrson

    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

     
  • Glenn Randers-Pehrson

    The change has been implemented in libpng-1.5.0beta33

    Glenn

     
  • Jan Nijtmans

    Jan Nijtmans - 2010-07-06

    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

     
  • Jan Nijtmans

    Jan Nijtmans - 2010-07-06

    patch to pngpriv.h

     
  • Glenn Randers-Pehrson

    Both fixes are in libpng-1.5.0beta34 and 1.4.4beta01.

     
  • Glenn Randers-Pehrson

    • status: open --> open-accepted
     
  • Glenn Randers-Pehrson

    • assigned_to: nobody --> glennrp
     
  • Glenn Randers-Pehrson

    • status: open-accepted --> open-fixed
     
  • Glenn Randers-Pehrson

    • status: open-fixed --> closed-fixed
     
  • Jan Nijtmans

    Jan Nijtmans - 2015-07-03

    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.

     
  • Glenn Randers-Pehrson

    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
  • Glenn Randers-Pehrson

    • status: closed-fixed --> pending
     
  • Glenn Randers-Pehrson

    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!

     
    • Jan Nijtmans

      Jan Nijtmans - 2015-07-03

      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

       
  • Glenn Randers-Pehrson

    Revised the patch to avoid introducing an API incompatibility.

     
  • Glenn Randers-Pehrson

    Here is a more complete patch by John Bowler. Please give it a try.

     
  • Jan Nijtmans

    Jan Nijtmans - 2015-07-03

    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)

     
  • Glenn Randers-Pehrson

    Assuming you did

    -DPNG_LINKAGE_API=

    or similar. Otherwise the "extern" will still appear.

     
  • Glenn Randers-Pehrson

    Closing as fixed. Reopen if you're still experiencing this bug.

     
  • Glenn Randers-Pehrson

    • status: pending --> closed-fixed
     

Log in to post a comment.