#ifdef KR void Fun (foo) float foo; #else void Fun (float foo) #endif { L = foo;
} / Fun () /
int main ()
{
Fun (foo);
return 0;
} / main () /
</pre></ul> <p> This can be compiled using the ANSI function prototype using: </p> <ul><pre> or32-elf-gcc -g -mor32-newlib call-test.c </pre></ul> <p> And as K&R function prototype using: </p> <ul><pre> or32-elf-gcc -g -mor32-newlib -DKR call-test.c </pre></ul> <p> This should be debugged with GDB, using the following commands </p> <ul><pre> file a.out target sim load break main run call Fun(foo) print /c L </pre></ul> <p> Fun should set the float global variable L to the value in the float global variable foo, which as a char is '1'. It works with the ANSI version, not the K&R version. </p> <p> It seems that the K&R version effectively treats the argument as double, even though declared float. However when called as a dummy function within GDB, the argument is set up as a float. </p> <p> Not clear if this is a generic GDB issue, or a fault in the OR32 function to set up a dummy call. </p> <p> No one is likely to write (and hence debug) K&R code today, but there is still a lot out there, so we should support this. For now the regression is run using -DPROTOTYPES in the C flags, which means all tests are compiled using prototypes. </p> <p> Jeremy </p> <p> -- <br /> Tel: +44 (1590) 610184<br /> Cell: +44 (7970) 676050<br /> SkypeID: jeremybennett<br /> Email: <a href="mailto:jeremy.bennett@embecosm.com">jeremy.bennett@embecosm.com</a><br /> Web: <a href="http://www.embecosm.com">www.embecosm.com</a> </p>