Quote:
|
Originally Posted by Darkman_X000
So, after the prescribed research, I still do not understand the "dangerous road" of floats and implicit initializations. Please enlighten me.
Thanx in advance.
|
Well, the issue with floats is that this micro does not have a Floating Point Unit. So, while on your PC the FPU would quicky preform any math involving floats, that all has to be emulated in software on this micro. That is bad becuase that emulation is fairly complex and could potentially slow down your program considerably, especially if you use alot of floating point numbers.
The concerns about the implicit initializations, is basically that normally on microprocessors, the line
int i = 5;
may not automatically initalize i = 5. Though that is really a moot point in this case since IFI has a routine that does initalize the variables for us. (in ifi_startup.c for those who haven't seen it.)
-----------------------
No, you can't use extern with #define. #define isn't actually a variable, what it means, is before the code is complied (in the pre-processor), the any time the first item after the #define is found, it is replaced with the second. So:
#define PI 3.1415926538
int C, R = 3;
C= 2*PI*R;
Becomes (after the pre-processor, but before the actuall compiler)
int C, R = 3;
C= 2*3.1415926538*R;
So if you just put the
#define axelWidth .725
in one header file, that you include everywhere, you can use axelWidth with no other effort.
------------------------------