The problem is likely that you don't have any floating point library linked to the project to begin with.
This is normal for any microcontroller application, since it doesn't make a whole lot of sense to use floating point numbers there. Particularly when the MCU has no built-in FPU. Because if it doesn't, you will get floating point handling through software, which is very slow.
Therefore, when doing embedded programming, you always avoid floating point arithmetic for as long as possible.
It is a common misunderstanding among PC programmers that floating point means: "I need to display a decimal comma". That's just nonsense, you can perform all calculations on plain integers and then only calculate and print the comma position when you need to present the value to a user. Floating point numbers will just cause problems (such as floating point inaccuracy causing problems during comparison).
For example, if your program needs to display volts, with 3 decimals of millivolts, you should not create a float volt = 1.234f;
variable, but rather a uint32_t milli_volt = 1234;
and then do all calculations on millivolts.
Floating point rather means: "I need to do advanced math." As a rule of thumb, you should not use floating point numbers unless your program needs to do advanced math such as trigonometry. In which case you should pick a MCU with built-in FPU.
That being said, you can still calculate numeric constants in the pre-processor, without actually involving any float calculations in your code. Example:
#define CURRENT 0.20
#define RESISTANCE 47.0
#define VOLTAGE (uint32_t) (CURRENT * RESISTANCE)
Here the floating point calculation will be performed by your programming PC and not the microcontroller. The above is equivalent to writing
#define VOLTAGE 9
#define
statement isn't required to support arithmetic at all -- it's supposed to be strictly a text substitution mechanism. Any semantics are determined by where the macro is actually used. If it is used in a subsequent#if
statement or something, THAT's where the error is occurring. \$\endgroup\$