From: geoff@plan9.bell-labs.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Include guards and multiple includes
Date: Mon, 23 Oct 2006 16:23:03 -0400 [thread overview]
Message-ID: <91b5ebacd2423c345a89544c3d45ed34@plan9.bell-labs.com> (raw)
In-Reply-To: <2ce618c636a8a74af13258cdeaa93de0@plan9.jp>
I'd think the set of cpp keywords needed would be: ifdef, ifndef,
else, endif, define, undef, and include. `line' is typically
generated by other preprocessors (e.g., yacc) not by people. `pragma'
is compiler-dependent, and we have uses for it on Plan 9, but most
uses are in system-supplied headers files, not ones you'd write;
`#pragma incomplete' is an exception.
The main use we advocated in the paper for conditional compilation was
providing default values, thus:
#ifndef COPYSIZE
#define COPYSIZE 8192
#endif
and Henry Spencer suggested that this idiom might have been profitably
bundled up as `#override symbol value' (`#ifndefdef' in the paper).
The paper dates from an era of considerable diversity among Unix
systems and the beginnings of migration to ANSI/ISO C and POSIX, so it
was a time of transition. These days I'm not using conditional
compilation or even cpp much. Plan 9 has shown us better alternatives
to conditional compilation, and looking at some of my recent code, I
see that I #include headers and #define an occasional macro for some
expression and not much else. enums have replaced #define for integer
constants, and that was always my main use for #define.
prev parent reply other threads:[~2006-10-23 20:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-20 18:45 Paul Lalonde
2006-10-20 19:27 ` Joel Salomon
2006-10-20 20:18 ` Russ Cox
2006-10-20 20:37 ` Paul Lalonde
2006-10-22 16:37 ` Joel Salomon
2006-10-23 12:29 ` Charles Forsyth
2006-10-20 23:15 ` geoff
2006-10-20 23:39 ` Bruce Ellis
2006-10-24 14:32 ` AtomicKobold Design
2006-10-23 12:39 ` Rogelio Serrano
2006-10-23 12:41 ` erik quanstrom
2006-10-23 12:52 ` Rogelio Serrano
2006-10-23 13:26 ` erik quanstrom
2006-10-23 15:30 ` Joel Salomon
2006-10-23 18:43 ` Charles Forsyth
2006-10-23 19:12 ` Joel Salomon
2006-10-23 20:23 ` geoff [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91b5ebacd2423c345a89544c3d45ed34@plan9.bell-labs.com \
--to=geoff@plan9.bell-labs.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).