returning a float from a BSP function

I am using NetOS 5.0 and GHS 3.5 I have added a function (read_float()) to the BSP which returns a float (i.e I rebuilt BSP etc). Using the debugger I can see that this function calculates the correct value. At my application level the returned float value is wrong. e.g. IN BSP float read_float(void) { float bv; … return(bv); // bv correct here } IN MY APP float bv; bv = read_float(); // bv is not correct ??? printf(“%06.4f”,bv); Both the BSP and my application project files are setup for as per the default settings that is “software float” and “big endian” Looking at the assembly it looks like the returned value is been trashed.

Michael,I’ve found that GreenHills won’t give a compiler/linker error when an external function (one not in the same source file) is called without first being prototyped. Instead, it just assumes that the return value for the unknown function is an int. This means that the value shown in read_float will not be the same as the value shown in IN_MY_APP because IN_MY_APP is interpreting those four bytes as an int, not a float. The solution is to be sure that you add the line “float read_float(void);” at the top of the source file that calls read_float. This lets the compiler know what the proper return value is. I hope this helps, James Fegan

thank you - I found the that for my application project the “function used w/o prototype” option was set to “silent” in the project options for “C language”. So I changed this to “warning”. This then gave the warning about the prototype and lots of other warnings even in code supplied by Netsilicon.