[sdiy] OT (but very synthy): C question

Jay Vaughan jayv at synth.net
Wed Mar 30 14:25:45 CEST 2011


I agree, typedef is really useless. 

;
--
seclorum 

On Mar 30, 2011, at 14:02, Thomas Strathmann <thomas at pdp7.org> wrote:

> On 3/30/11 13:05 , Tom Wiltshire wrote:
>> It's annoying that in C you can forward-declare a struct, but can't do the same thing with a typedef.
>> The following is possible..
>> 
>> typedef struct LFO LFO;
>> 
>> ..but this just forward-declares the struct, then creates a type from it. Since it's a definition (of a new type) you can't use this like you would a forward declaration. If you attempt to, you'll get a "redefinition of typedef" error.
>> This means that you finish up having to scatter the 'struct' keyword all over your function prototypes (like Olivier does below) because you can't typedef the struct again, and makes the 'typedef' keyword considerably less useful than it could have been in my view.
> 
> For whatever it's worth, I'm actually in favour of using the struct keyword instead of using typedef. It might not be that pretty, but at least you know exactly from the type-signature of a function prototype what kind of values it deals with without having to look up the user-defined types first. I consider it a little more readable, but YMMV.
> 
>    Thomas
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy



More information about the Synth-diy mailing list