Re: [SLUG] GCC -- anomaly or feature?

From: Jason Copenhaver (jcopenha@typedef.org)
Date: Wed Aug 15 2001 - 22:02:08 EDT


I imagine this has to do with the way C passes function parameters.. It
puts them on the stack from right to left.. This makes it easy to do
things like variable parameter functions.. I thought there was a way to
force C/gcc to use Pascal like function calls.. just can't seem to find
anything about it at the moment..

Jason

 On Wed, 15 Aug 2001, Ed Centanni wrote:

> I found out today that when you call a function with functions as
> arguments:
>
> DoThisThing(with1(thing), with2(thing), with3(thing));
>
> the "with" functions do not get called in left to right (1,2,3) order.
> I had to break them out thus:
>
> int a = with1(thing);
> int b = with2(thing);
> int c = with3(thing);
> DoThisThing(a,b,c);
>
> to ensure that the functions were called in the right order.
>
> My question is: Is there a compiler option that forces the arguments to
> be evaluated in the desired (left-to-right) order. I tried -O0 (that's
> dash oh zero -- no optimizations) and the always popular
> -fno-defer-pop. No joy. BTW, that last one is NOT a compiler option
> to tell gcc to dis your dad.
>
> Also, "thing" is a pointer to a pointer that get modified (advanced down
> a string) on each "with" invocation. I know it's not good form but I
> have to deal with some existing code.
>
> TIA
> Ed.
>
>



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:29:14 EDT