unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* #if vs #ifdef
@ 2003-03-27  6:18 Rob Browning
  2003-03-27  9:43 ` tomas
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Rob Browning @ 2003-03-27  6:18 UTC (permalink / raw)



The GNU Coding Standards suggest always #defining a symbol to a value
and using #if tests rather than either defining or not defining that
symbol and using #ifdef or #ifndef.  i.e. instead of "#define FOO",
use "#define FOO 1", and use "#define FOO 0" rather than not defining
it at all.

One reason for this recommendation is that they then encourage you to
write code like this:

  if (SCM_HAVE_ARRAYS)
    {
      ...

rather than using #if/#ifdef/etc. at all.  Their argument is that all
reasonable compilers will generate the same code either way, and using
C code rather than the preprocessor can substantially improve the
readability of the code and allow the C compiler to do more thorough
analysis of all code paths.

Thoughts?  Since I just added new public defines, this seems a good
time to ask.

Thanks

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-03-27 19:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-27  6:18 #if vs #ifdef Rob Browning
2003-03-27  9:43 ` tomas
2003-03-27 12:48 ` Dale P. Smith
2003-03-27 15:26   ` tomas
2003-03-27 15:08     ` Dale P. Smith
2003-03-27 15:56   ` Rob Browning
2003-03-27 15:13 ` Marius Vollmer
2003-03-27 19:47   ` Rob Browning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).