This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: something that would be nice
- From: "John S. Dyson" <toor at y dot jdyson dot com>
- To: mwells at gigablast dot com
- Cc: mrs at apple dot com (Mike Stump), gcc at gcc dot gnu dot org
- Date: Wed, 12 Nov 2003 00:21:03 -0500 (EST)
- Subject: Re: something that would be nice
>
> 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