See below...

On 09/06/2011, at 2:59 PM, Josh Gargus wrote:

>>> I really don't understand what this means:
>>> 
>>> typedef struct object *(*method_t)(struct object *receiver, ...);
>>> 
>>> method_t is a pointer to a function that returns an object pointer and 
>>> takes receiver and additional argument
>> 
>> Thanks for this. Okay, I understand that, but why is there a "struct" in 
>> there twice? considering object is defined as a struct earlier in the 
>> piece... is it because they're object pointers? when specifying a struct 
>> pointer, do you need to write "struct" even though you've previously 
>> specified a struct with that name?
> 
> The latter.  In C++ you only need to use struct when declaring the type.   
> However, in C you need to explicitly use struct every time you want to refer 
> to the type.
> 
> One common idiom is to use a typedef while defining the type.  In this case, 
> you might write:
> 
> typedef struct object object_t;
> typedef object_t *(*method_t)(object_t *receiver, ...);
> 

Okay, so in the initial example, why the typedef? What function is it 
performing here? I thought typedef was used to alias types, and yet here it 
doesn't seem to be doing anything... if method_t is a function pointer, why 
does there need to be a typedef in front of it? 

Sorry I'm so dense. :S

Julian.
_______________________________________________
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc

Reply via email to