Re:Declaring C String Constants
by khaled on Wednesday May 17, 2017 @02:36PM
(#14361441)
GCC has -Wstrict-prototypes.
[ Parent
| on HN ]
Re:Declaring C String Constants
by iainmerrick on Wednesday May 17, 2017 @04:14PM
(#14362388)
Strange that that isn't included in -Wall! I knew -Wall isn't the same as -Weverything, but I'm always surprised at what it omits. Why wouldn't you want that warning?
Edit to add: Aha, my 'gcc' was actually Clang because I'm on OS X. Installing the real GCC, I find:
gcc -Wstrict-prototypes does what I want and disallows this feature. But -Wall doesn't include that flag, and GCC doesn't seem to have -Weverything.
Clang accepts -Wstrict-prototypes but doesn't catch no-arg functions! That's bad. Even with -Weverything, Clang lets you do anything you want with no-arg functions. Very bad.
I think it is not included in -Wall because such prototype are legitimate pre-ANSI K&R C function prototypes.
Re:Declaring C String Constants
by iainmerrick on Wednesday May 17, 2017 @08:30PM
(#14364011)
Hmm, could be! Maybe explicitly specifying a newer standard might do the trick then. I'll try a few things.