I was informed that if I want to return a struct from a function I should typedef it. In regards to typedef'ing, which is the proper syntax for it. I tried reading up on it, but ended up more confused. My goal, create a struct, fill it with goodies and return it from a function.
This:
1 2 3 4 5
typedefstruct {
int passedChannels;
int passedSamples;
short **passedBuffers;
}BUFFER;
Or this:
1 2 3 4 5
typedefstruct BUFFER{
int passedChannels;
int passedSamples;
short **passedBuffers;
};
Or finally this:
1 2 3 4 5
typedefstruct BUFFER{
int passedChannels;
int passedSamples;
short **passedBuffers;
}buffer;
I was informed that if I want to return a struct from a function I should typedef it.
You should not.
1 2 3 4 5 6 7 8 9 10 11
struct buffer{
int passedChannels;
int passedSamples;
short **passedBuffers;
};
buffer someFunction()
{
buffer aNiceNewObject; // make a buffer object
return aNiceNewObject; // return it
}
the first 2 and the one that Moschops shower are completly the same, while the third makes 2 indentical structures, BUFFER and buffer.
So, yes, all of them are wrong, becouse typedefing structures is stupid :D