On 2017-02-01 16:44:31 +0100, David Brown wrote: > On 01/02/17 15:13, Mason wrote: > > On 01/02/2017 14:52, Jonathan Wakely wrote: > >> On 1 February 2017 at 13:49, Mason wrote: > >>> Hello, > >>> > >>> https://gcc.gnu.org/gcc-5/porting_to.html states > >>> > >>> "Typically, this macro is used as in the following: > >>> > >>> #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L > >>> /* ... */ > >>> #else > >>> # include <stdint.h> > >>> #endif > >>> " > >>> > >>> I think it is unnecessary to test for the existence of __STDC_VERSION__ > >>> because N1256 6.10.1p4 states > >>> "all remaining identifiers [...] are replaced with the pp-number 0" > >>> > >>> Therefore > >>> #if __STDC_VERSION__ < 199901L > >>> would work as expected, even when __STDC_VERSION__ is undefined. > >>> (As the constant-expression would be false.) > >> > >> But you'd get a warning with -Wundef > > > > Right. > > > > I'm not convinced by the usefulness of -Wundef, though. > > > > I suppose its only use is catching typos such as > > > > #define FOO 42 > > #if GOO > > #endif > > > > which would silently discard the conditional code. > > > > -Wundef is useful /precisely/ because it catches such mistakes. However, it yields false positives on code that doesn't contain any ambiguity (and is easier to read than lengthier code), such as: #if __STDC_VERSION__ < 199901L Since __STDC_VERSION__ is a standard macro, it is quite obvious that even if __STDC_VERSION__ is not defined, this is not a typo. So, IMHO, -Wundef should whitelist some common macros (and/or perhaps let the user provide his own whitelist). -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)