dankogai / p5-encode

Encode - character encodings (for Perl 5.8 or better)
https://metacpan.org/release/Encode
37 stars 51 forks source link

Only add -Werror=declaration-after-statement for 5.035004 and earlier #162

Closed nwc10 closed 3 years ago

nwc10 commented 3 years ago

Perl v5.35.5 now uses some C99 features. This means that Perl's headers now contain some code with mixed declarations and code., and so won't compile with -Werror=declaration-after-statement

It still makes sense to add this flag for builds for earlier perl versions, because they support long obsolete compilers that are strict in rejecting certain C99 features, so adding this gcc flag allows us to audit that our code does not violate this.

We didn't need this change in blead, because these flags are only added when $ENV{PERL_CORE} is false.

Without this change, Encode built from git against blead now fails to build (due to code in blead deliberately changed to find such problems early):

/home/nick/Sandpit/snap-v5.35.4-120-gc44af6e357-ig/lib/perl5/5.35.5/x86_64-linux-thread-multi/CORE/inline.h: In function ‘Perl_av_store_simple’:
/home/nick/Sandpit/snap-v5.35.4-120-gc44af6e357-ig/lib/perl5/5.35.5/x86_64-linux-thread-multi/CORE/inline.h:91:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
     SV **ary = AvARRAY(av);
     ^~
cc1: some warnings being treated as errors
nwc10 commented 3 years ago

5.035004 and earlier - why do I never spot these things until after I've pushed, despite re-reading things twice before...

dankogai commented 3 years ago

Thank you!