This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]