[Shootout-list] Problems building GCC C Fibonacci.

Falk Hueffner falk@debian.org
Mon, 21 Mar 2005 08:21:20 +0100


"Dave" <davejf@frontiernet.net> writes:

> unsigned long
> fib(unsigned long n) {
>     return( (n < 2) ? n : (fib(n-2) + fib(n-1)) );
> }
>
> int
> main(int argc, char *argv[]) {
>     int N = ((argc == 2) ? atoi(argv[1]) : 1);
>     printf("%ld\n", fib(N));
>     return(0);
> }

You might consider marking fib "static". That gives the compiler the
freedom to choose argument passing conventions itself. I think recent
gccs even exploit this on i386, where the default conventions are not
quite optimal.

-- 
	Falk