something that would be nice
John S. Dyson
toor@y.jdyson.com
Wed Nov 12 08:07:00 GMT 2003
>
> oh, follow up question.
> if i had a bunch of these functions in one file wouldn't i have
> to do it like:
> struct foo1 { int i; int j; } bar () ;
> struct foo2 { int i; int j; } bar () ;
> struct foo3 { int i; int j; } bar () ;
> ...
> ?
I am a C language user and not an architect or laywer,
but you might try something like this:
typedef struct _rtpair
{
int i, j;
} rtpair;
Then, your function can be defined like:
rtpair
bar(arg0type arg0, arg1type arg1, argntype argn)
{
rtpair rtval;
/* Misc C stuff */
rtval.i = rtitem0;
rtval.j = rtitem1;
return rtval;
}
In C++, the return sequence could be something like:
return rtpair(rtitem0, rtitem1);
which is syntatically nicer.
I do strongly suggest some help in advanced C and
C++ programming, because there might also be some
other things that might be helpful for you.
C++ has a little more typechecking and other features
that can be useful (e.g. typechecking enums, etc), even
if you don't need more advanced features for OO programming.
John
More information about the Gcc
mailing list