Re: Could -Wall add on -Wundef by default ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 02/03/2019 20:36, Jonathan Wakely wrote:
On Sat, 2 Mar 2019 at 13:35, Jonny Grant <jg@xxxxxxxx> wrote:



On 22/02/2019 15:41, David Brown wrote:
On 22/02/2019 15:29, Jonny Grant wrote:
Would be good for -Wundef to be on by default

We see a few times code silently left out of a build unless we use -Wundef

Example below, the bug is this file didn't have a #define PROJ_DEF 1

Jonny

// gcc -Wall -Wextra -c pre.c
#include <stdio.h>
int main()
{
#if PROJ_DEF
      printf("hello\n");
#endif

      return 0;
}


I think far too much code relies on this sort of construct and would
throw up warnings while otherwise passing -Wall cleanly.

As far as I can see from the C standards, using "#if PROJ_DEF" without
defining the macro "PROJ_DEF" is not allowed, but I could be wrong - and
it certainly has been common usage even if the standards disallow it.

Perhaps just adding to -Wextra would make sense?

I would still be strongly against that. Why can't you just use
-Wundef, instead of forcing everybody else to change their code to
follow your preferred convention?

Yes, we use it. Presumably someone decided what should go into -Wextra, and presumably it is things that are worth adding... in my view it's worth adding. No worries if that isn't consensus though! :)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux