home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!uunet.ca!geac!r-node!druid!darcy
- From: darcy@druid.uucp (D'Arcy J.M. Cain)
- Subject: Re: HIgher problems at hand. HELP!
- Message-ID: <1992Jul28.104059.4725@druid.uucp>
- Date: Tue, 28 Jul 1992 10:40:59 GMT
- References: <1992Jul25.142216.5636@druid.uucp> <9220806.7841@mulga.cs.mu.OZ.AU> <1992Jul27.212311.28125@zooid.guild.org>
- Organization: D'Arcy Cain Consulting
- Lines: 31
-
- Ross Ridge <ross@zooid.guild.org> writes:
- >fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- >>darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- >>>#define const
- >>Do *not* #define keywords unless you have absolutely no alternative.
- >>>#include <string.h>
- >>Now what happens if string.h happens to contain
- >> const CHAR_BIT = 8;
- >>or some such?
- >Include files are very unlikely to contain external definitions like this.
- >Remeber in C there is world of difference between "#define CHAR_BIT 8"
- >and "/*static*/ const /*int*/ CHAR_BIT = 8;". But who knows what's
- >in <string.h> so it would be better if the "#define const" was placed
- >after the "#include <string.h>".
-
- Except that the whole point is to prevent any warnings with full checking
- turned on. Putting the define after the include would cause warnings
- when strstr was redefined. Note that you can't leave it off either since
- the function calls both strlen and strncmp.
-
- Other than changing the language itself I don't believe there is a "right"
- way to code strstr(3). Anything you do is a kluge. My kluge simply has
- the benefit of not producing warnings. However you do have to be aware
- in case you do have that really strange hardware where this doesn't work.
- That's why I put four lines of comment before the define.
-
- --
- D'Arcy J.M. Cain (darcy@druid.com) |
- D'Arcy Cain Consulting | There's no government
- Toronto, Ontario, Canada | like no government!
- +1 416 424 2871 DoD#0082 |
-