--- Begin Message ---
Subject: |
fencepost:/home/gd/gnuorg/standards.texi -- recent changes |
Date: |
Wed, 15 Aug 2001 06:10:05 -0400 |
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:
address@hidden lastupdate March 23, 2001
address@hidden lastupdate August 14, 2001
@c %**end of header
@ifinfo
@@ -60,7 +60,7 @@
@titlepage
@title GNU Coding Standards
address@hidden Richard Stallman
address@hidden 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
+
address@hidden Conditional Compilation
address@hidden 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
+
address@hidden
+ if (HAS_FOO)
+ ...
+ else
+ ...
address@hidden smallexample
+
+instead of:
+
address@hidden
+ #ifdef HAS_FOO
+ ...
+ #else
+ ...
+ #endif
address@hidden 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
address@hidden as in the following example:
+
address@hidden
+ #ifdef REVERSIBLE_CC_MODE
+ #define HAS_REVERSIBLE_CC_MODE 1
+ #else
+ #define HAS_REVERSIBLE_CC_MODE 0
+ #endif
address@hidden smallexample
+
address@hidden Standard C and Pre-Standard C
address@hidden @sc{ansi} C standard
@node Program Behavior
@chapter Program Behavior for All Programs
--- End Message ---