Skip to content

Functions without prorotypes cause -Wstrict-prototypes warnings #633

@MaskRay

Description

@MaskRay

As of Clang 14.0.0, compiling zlib with -Wstrict-prototypes is warning free.

The next Clang release 15.0.0 will include https://reviews.llvm.org/D122895 which has improved diagnostics. Notably: the new -Wdeprecated-non-prototype is enabled by default which warns many declarations in zlib:

% make CC=/tmp/RelA/bin/clang -j 30                                                                                                                                                                                                                                                         
/tmp/RelA/bin/clang -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -I../../ -c -o example.o ../../test/example.c                                                                                                                                                                             
/tmp/RelA/bin/clang -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -include zconf.h -c -o adler32.o ../../adler32.c                                                                                                                                                                              
...                                                                                                                                                   
../../compress.c:22:13: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]                                                                                                                     
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)                                                                                                                                                                                                                             
            ^                                                                                                                                                                                                                                                                               
../../compress.c:68:13: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]                                                                                                                     
int ZEXPORT compress (dest, destLen, source, sourceLen)                                                                                                                                                                                                                                     
            ^                                                                                                                                                                                                                                                                               
../../compress.c:81:15: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]                                                                                                                     
uLong ZEXPORT compressBound (sourceLen)                                                                                                                                                                                                                                                     
              ^                                                                                                                                                                                                                                                                             
../../uncompr.c:27:13: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]                                                                                                                      
int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)                                       

[...]

There are also a few -Wstrict-prototypes -Wno-deprecated-non-prototype diagnostics.

Note: -pedantic will imply -Wstrict-prototypes.


As of GCC 11, its -Wstrict-prototypes warns about some declarations (a small subset of Clang's list):

../../crc32.c:117:16: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
  117 | local z_word_t byte_swap(word)
      |                ^~~~~~~~~
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -include zconf.h -DPIC -c -o objs/gzclose.o ../../gzclose.c
../../crc32.c:717:15: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
  717 | local z_crc_t crc_word(data)
      |               ^~~~~~~~
../../crc32.c:726:16: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
  726 | local z_word_t crc_word_big(data)
      |                ^~~~~~~~~~~~
../../crc32.c:1093:15: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
 1093 | uLong ZEXPORT crc32_combine_gen64(len2)
      |               ^~~~~~~~~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions