I have an Objective C project incorporating a C file with some helper functions. I have a grave and very irritating problem trying to return float
s from the C file.
C file:
float returnFloat() {
return 10.0;
}
Meanwhile in an Objective C instance method:
float x;
x = returnFloat();
x is always 0.000000. Any ideas what I'm doing wrong?
Edit
OK, I've realised I have a bunch of "implicit declaration" warnings in the Objective C file, relating to use of the functions I have in the C file.
Assignments using functions that return int
s are working fine. Where an assignment is made from a function returning a float
, the debugger says "variable optimized away by compiler".
Is it likely I'm not using the "correct" way to include a C file containing helper functions in an Objective C project? I have (stupidly?) just let Xcode link it in automagically. Even if so, why should this problem manifest only when the function is returning a float
?