Why pass structs? (not struct p
aglew at ccvaxa.UUCP
aglew at ccvaxa.UUCP
Thu Mar 12 13:48:00 AEST 1987
...> Why pass structs by value?
I occasionally feel uncomfortable passing structs by value,
and receiving them as the return value of the function.
Frequently because the struct starts offsmall, 16 - 32 bits
(eg. struct RectCoord { short x, y; }), so I say "I should use
pass by value here because they structure is no bigger than an
int". But then I start adding stuff to the struct, more fields,
reference counts...
The only things that I don't feel guilty about are
typedef struct Complex {
float re, im;
} Complex;
and
typedef LongLong {
unsigned hi, low;
} LongLong;
the latter because the machine I work on has 64 bit integer instructions,
though the C compiler doesn't give you access to them.
More information about the Comp.lang.c
mailing list