samurai icon indicating copy to clipboard operation
samurai copied to clipboard

build: Update warning flags

Open orbea opened this issue 3 years ago • 1 comments

This has 3 changes.

~~1. Remove -Wno-unused-parameter. There are currently no warnings and its probably better to solve these with if (foo) {} in the cases they exist to prevent hiding legitimate warnings.~~ 2. Adds -Wshadow and fixes the one warning revealed by both gcc and clang. 3. Adds -Wmissing-prototypes which doesn't reveal any existing warnings, but it would be nice to not inadvertently introduce it in the future. 4. Fixes a -Wcpp warning.

This was tested on Slackware with gcc-11.2.0/clang-13.0.0 and Gentoo with gcc-11.3.0/clang-14.0.6.

The fixed -Wshadow warning:

samu.c: In function ‘main’:
samu.c:187:21: warning: declaration of ‘n’ shadows a previous local [-Wshadow]
  187 |                 int n = sysconf(_SC_NPROCESSORS_ONLN);
      |                     ^
samu.c:126:22: note: shadowed declaration is here
  126 |         struct node *n;
      |                      ^
In file included from /usr/include/errno.h:25,
                 from build.c:5:
/usr/include/features.h:187:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~

orbea avatar Jul 13 '22 15:07 orbea

but I think -Wno-unused-parameter should stay.

I added it back.

orbea avatar Jul 21 '22 01:07 orbea

Thanks! Merged.

michaelforney avatar Jun 17 '23 18:06 michaelforney