Re: I don't understand typedef example
- From: André Hänsel <andre@xxxxxxxx>
- Date: Sun, 22 Mar 2009 18:34:57 -0700 (PDT)
On 23 Mrz., 01:17, pete <pfil...@xxxxxxxxxxxxxx> wrote:
André Hänsel wrote:
Thanks for all your answers. They make it clear. So I understand that
all the author wanted to say is that there is no syntax in C to use a
typedef'd function type to define (or even declare) a function of that
type.
Since the only use of such a typedef is to make a type "pointer to
such a function" I probably will stick to the "typedef int
*pointer_to_such_function(int,int)" syntax in my own code.
Did you understand the part of the answers
which explained about the author being wrong?
You *can* use a typedef to declare a function.
Actually I don't think the author is wrong but he expresses the facts
in a very unfortunate way. I think by the sentence "As a word of
warning, typedef can only be used to declare the type of return value
from a function, not the overall type of the function." he means
something like "The typedef'd 'type name' cannot be used to define a
function of this type, it can only be used to define a function
returning a pointer to a funtion of this type."
This is what you meant by "using a typedef to declare a function",
isn't it? Or is there really a way to define a function of this very
type?
.
- Follow-Ups:
- Re: I don't understand typedef example
- From: Keith Thompson
- Re: I don't understand typedef example
- From: pete
- Re: I don't understand typedef example
- References:
- I don't understand typedef example
- From: André Hänsel
- Re: I don't understand typedef example
- From: André Hänsel
- Re: I don't understand typedef example
- From: pete
- I don't understand typedef example
- Prev by Date: Re: no declaration inside for loop header
- Next by Date: Re: On the development of C
- Previous by thread: Re: I don't understand typedef example
- Next by thread: Re: I don't understand typedef example
- Index(es):
Relevant Pages
|