Will it execute everywhere ?

Tom Tkacik tkacik at kyzyl.mi.org
Mon Jul 30 01:00:42 AEST 1990


In article <831 at gtenmc.UUCP>, csp at gtenmc.UUCP (Charudutta S. Palkar) writes:
> 	Will this piece of code execute irrespective of the order
> 	in which the parameters are pushed on the stack ie. right
> 	to left or left to right? This is executable on Unix V.3
> 	on a VAX-8000.
 
> 	void ftest(n)
> 	int n;
> 	{
> 	   char **p;
> 	   p = (char **)( &n + 1 );
> 	   while( n-- )
> 	      printf("%s",*p++);
> 	}


This is not portable.  It requires that the stack grow down.
Some machines (eg. AT&T WE32000, used in 3b2's) have a stack that grows up.
Others pass the first few parameters in registers.

To be portable, use varargs.


-- 
Tom Tkacik		tkacik at kyzyl.mi.org
Speaking only for myself here in Royal Oak.



More information about the Comp.lang.c mailing list