Article View: comp.std.c
Article #5978Re: Multiple typedefs
From: Dave Collier-Brown
Date: Sun, 30 Apr 1989 15:33
Date: Sun, 30 Apr 1989 15:33
38 lines
2054 bytes
2054 bytes
In article <2322@lethe.UUCP> drew@lethe.UUCP (Drew Sullivan) writes:
| typedef unsigned int foo_t; /* from include file 1 */
| extern foo_t foo(void);
| typedef unsigned int foo_t; /* from include file 2 */
| extern foo_t foo(void);
In article <10167@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes:
| No, the second typedef is syntactically invalid.
| The conventional way to guard against this is:
| #ifndef _FOO_T_DEFINED
| #define _FOO_T_DEFINED
...
It is interesting that one has to use ifdefs to protect a redefinition
of a typedef but not of a macro. In P.J. Plauger's column on Standard C [1]
he comments..
The committee eventually permitted one form of refefinition,
however. Plum insisted we allow "benign" redefinition of a macro.
Loosely speaking, a macro definition is benign if it results in
essentially the same definition as before. Permitting benign
redefinition, Plum argues, greately simplifiees writing the same
definition in multiple #include files. (The Standard C library has
multiple definitions of the macro NULL, for instance.)
Is there a technical reason for the difference in redefinition rules
for macros -vs- typedefs, or is it present for administrative or
historical reasons? Or is it an error?
--dave c-b
ps: the above is something close to the meaning of Drew's initial
question.
--
David Collier-Brown, | {toronto area...}lethe!dave
72 Abitibi Ave., | Joyce C-B:
Willowdale, Ontario, | He's so smart he's dumb.
CANADA. 223-8968 |
Technical Details
Message-ID:
<2402@lethe.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!dptcdc!berner!lethe!daveReferences:
<2322@lethe.UUCP> <10167@smoke.BRL.MIL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!dptcdc!berner!lethe!dave From: dave@lethe.UUCP (Dave Collier-Brown) Newsgroups: comp.std.c Subject: Re: Multiple typedefs Summary: ...appear inconsistent with multiple macros Keywords: typedefs, includes, defines Message-ID: <2402@lethe.UUCP> Date: 30 Apr 89 15:33:06 GMT References: <2322@lethe.UUCP> <10167@smoke.BRL.MIL> Reply-To: dave@lethe.UUCP (Dave Collier-Brown) Organization: Interleaf Canada, News courtesy of Systems Software Lines: 38