On Fri, Feb 17, 2023 at 11:49:58AM +0000, Richard W.M. Jones wrote: > On Wed, Feb 15, 2023 at 01:48:39PM -0600, Eric Blake wrote: > > In my experience with GNU code (which this is not), the style I've > > seen there is to omit () whenever possible, as in: > > > > #if defined __GNUC__ > > > > or even > > > > #ifdef __GNUC__ > > I didn't know this was possible. > > I checked it. GCC and clang with -std=c89 and -std=c99 allow this, so > I don't object. > > Although we don't support (eg) MSVC do you know if this is really > standard C?
C17 section 6.10.1P1: "The expression that controls conditional inclusion shall be an integer constant expression except that: identifiers (including those lexically identical to keywords) are interpreted as described below;168) and it may contain unary operator expressions of the form defined identifier or defined ( identifier ) which evaluate to 1 if the identifier is currently defined as a macro name (that is, if it is predefined or if it has been the subject of a #define preprocessing directive without an intervening #undef directive with the same subject identifier), 0 if it is not." Presumably similar in the upcoming C23, although I didn't check it. It's standard. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs