Re: how to define a function pointer variable witout typdef?
- From: "S.Tobias" <siXtY@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 29 May 2005 23:49:13 GMT
Keith Thompson <kst-u@xxxxxxx> wrote:
> Joe Wright <joewwright@xxxxxxxxxxx> writes:
> > Nice side step. In what way is a typedef a declaration creating a
> > named entity?
> The entity it creates is a named alias for an existing type. An
> "entity", as I'm using the term, doesn't have to be something that
> occupies memory space; it's just something that can be named.
A typedef declaration just creates another identifier, with
all its consequences.
I'd say a typedef name is even less than an alias, more like
a macro definition:
typedef struct s s_t;
/* s_t is an incomplete type here */
struct s { /*...*/ }; /* creates new type, redeclares `s', implicitly
redeclares (redefines) s_t */
/* s_t is a (different) complete type now */
The meaning of a typedef name depends on the context (therefore we
cannot say that it aliases some _particular_ type).
> Given:
> typedef int foo_t;
> "foo_t" is the name of an entity (the alias) that wouldn't exist
> without the typedef. Without the typedef, there isn't anything called
> "foo_t". (The type int does already exist, but that's not what's
> being declared.) By contrast,
[snip]
But then why other declarations are not definitions?
`foo_t' is just another name for `int' type.
struct s;
creates new type and gives it a name `s' (in tag namespace).
Why doesn't this declaration _define_ the identifier `s'?
(Interestingly, `struct s;' does not "define a new type", but "declares
a new type", 6.7.2.3 p.5 and p.7; this is another mystery what
the difference is.)
--
Stan Tobias
mailx `echo siXtY@xxxxxxxxxxxxxxxxxxxxxxxxxx | sed s/[[:upper:]]//g`
.
- Follow-Ups:
- Re: how to define a function pointer variable witout typdef?
- From: Keith Thompson
- Re: how to define a function pointer variable witout typdef?
- References:
- how to define a function pointer variable witout typdef?
- From: baumann@pan
- Re: how to define a function pointer variable witout typdef?
- From: sathyashrayan
- Re: how to define a function pointer variable witout typdef?
- From: sathyashrayan
- Re: how to define a function pointer variable witout typdef?
- From: Keith Thompson
- Re: how to define a function pointer variable witout typdef?
- From: Joe Wright
- Re: how to define a function pointer variable witout typdef?
- From: Keith Thompson
- Re: how to define a function pointer variable witout typdef?
- From: Joe Wright
- Re: how to define a function pointer variable witout typdef?
- From: Keith Thompson
- how to define a function pointer variable witout typdef?
- Prev by Date: Re: Difference between '\0' and 0
- Next by Date: Re: why?
- Previous by thread: Re: how to define a function pointer variable witout typdef?
- Next by thread: Re: how to define a function pointer variable witout typdef?
- Index(es):
Relevant Pages
|
|