Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Is typedef char BUFFER[20] legal?
Message-ID: <1991Feb10.002746.29506@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1212@tredysvr.Tredydev.Unisys.COM> <1991Jan29.210100.8105@zoo.toronto.edu> <22642@netcom.UUCP> <23128@netcom.COM>
Date: Sun, 10 Feb 1991 00:27:46 GMT

In article <23128@netcom.COM> avery@netcom.COM (Avery Colter) writes:
>My impression now, preparing my shoulder for more, is that
>typedef is tacked in front of a normal declaration in order
>to have the name treated as the name of a type rather than
>the name of an object, and that declaring a variable of the
>derived type is equivalent to making a non-typedef declaration
>exactly like that to which typedef was prepended, only with
>the new variable name occurring exactly where the derived
>type name was in the typedef declaration.

Essentially correct; your shoulder can relax :-).  The one small addendum
I would make is that there are a few circumstances which can arise only
through the use of typedefs, because they are syntactically impossible
in normal declarations.  For example:

	typedef int a_t[10];
	const a_t a;

attempts to make a const array of int, instead of the array of const int
one would get through a combined declaration.  In fact, the result is the
same, because there is a clause in ANSI C stating specifically that the 
const "falls through" in this case, affecting the inner type rather than
the array as a whole.
-- 
"Maybe we should tell the truth?"      | Henry Spencer at U of Toronto Zoology
"Surely we aren't that desperate yet." |  henry@zoo.toronto.edu   utzoo!henry
