Hm... What do you people think about this? After all, the core code of projects is not supposed to contain any HAVE_. Rather, AC_REPLACE_FUNCS etc. should be used, system.h for other issues, so it seems to me that this is a better solution than having #if HAVE_ in the main code, but worse than having no such HAVE_ at all. They should promote the latter IMHO. OTOH, is it really the purpose of the GCS to include such information? That pertains to autoconf.texi IMHO.
This is an automated report from fencepost. Recent changes to /home/gd/gnuorg/standards.texi: 124 -r--r--r-- 1 bkuhn user 121517 Aug 14 13:39 /home/gd/gnuorg/standards.texi diff -u -b /gd3/diffmon/diffmon/old_file_dir/fencepost/fencepost:!home!gd!gnuorg!standards.texi.gz /home/gd/gnuorg/standards.texi --- /tmp/diffmon11658 Wed Aug 15 06:10:05 2001 +++ /home/gd/gnuorg/standards.texi Tue Aug 14 13:39:15 2001 @@ -3,7 +3,7 @@ @setfilename standards.info @settitle GNU Coding Standards @c This date is automagically updated when you save this file: -@set lastupdate March 23, 2001 +@set lastupdate August 14, 2001 @c %**end of header @ifinfo @@ -60,7 +60,7 @@ @titlepage @title GNU Coding Standards -@author Richard Stallman +@author Richard Stallman, et al. @author last updated @value{lastupdate} @page @@ -99,6 +99,7 @@ * Managing Releases:: The Release Process * References:: References to Non-Free Software or Documentation * Index:: + @end menu @node Preface @@ -272,6 +273,7 @@ * Compatibility:: Compatibility with other implementations * Using Extensions:: Using non-standard features * Standard C:: Using Standard C features +* Conditional Compilation:: Compiling Code Only If A Conditional is True @end menu @node Source Language @@ -462,6 +464,57 @@ #define P_(proto) () #endif @end example + +@node Conditional Compilation +@section Conditional Compilation + +When supporting configuration options already known when building your +program we prefer using @code{if (... )} over conditional compilation, +as in the former case the compiler is able to perform more extensive +checking of all possible code paths. + +For example, please write + +@smallexample + if (HAS_FOO) + ... + else + ... +@end smallexample + +instead of: + +@smallexample + #ifdef HAS_FOO + ... + #else + ... + #endif +@end smallexample + +A modern compiler such as GCC will generate exactly the same code in +both cases, and we have been using similar techniques with good success +in several projects. + +While this is not a silver bullet solving all portability problems, +following this policy would have saved the GCC project alone many person +hours if not days per year. + +In the case of function-like macros like @code{REVERSIBLE_CC_MODE} in +GCC which cannot be simply used in @code{if( ...)} statements, there is +an easy workaround. Simply introduce another macro +@code{HAS_REVERSIBLE_CC_MODE} as in the following example: + +@smallexample + #ifdef REVERSIBLE_CC_MODE + #define HAS_REVERSIBLE_CC_MODE 1 + #else + #define HAS_REVERSIBLE_CC_MODE 0 + #endif +@end smallexample + +@section Standard C and Pre-Standard C +@cindex @sc{ansi} C standard @node Program Behavior @chapter Program Behavior for All Programs
