[sdiy] OT: questions on TYPEDEF STRUCT

Thomas Strathmann thomas at pdp7.org
Fri May 6 17:35:09 CEST 2011


On 5/6/11 16:55 , dan snazelle wrote:
> A little while back I asked the list a question that ended up in a discussion of STRUCT and since then I have learned what I can about it.
>
> One of the things I keep running into is code where people convert a STRUCT like this
>
>
> struct time
> {
> 	int hour;
> 	int minutes;
> 	int seconds;
> 	
> };
>
>
> into this:
>
> typedef struct time newTime
>
> and then you use newTime instead of the struct time .
>
>
> WHY?
>
> Why is this better, etc..there must be problems with struct, right?

I recall that this issue was already discussed a while ago with some 
people preferring the typedef approach and others (like me) preferring 
to spell out the struct every time to make clear that it's a struct (and 
not a union or some more complex user defined type) we're talking about 
it. In the end it does not matter much as you are probably not writing 
libraries that will be used by a bunch of other people. But if you do, 
I'd avoid typedefs as well as using the preprocessor too much.

	Thomas



More information about the Synth-diy mailing list