Float and double data types area a bad choice for embedded applications. At least in most applications, and can or should be avoided, even with hardware FPU support present. The MCU on Eclipse blog looks at the process.
Floating point operations or float and double data types are something I avoid in embedded applications: in most cases float and double data types are not necessary and only cause precision and code size and performance issues. Even with an FPU present it is problematic. Another good read is here: https://www.embedded.com/floating-point-data-in-embedded-software/
The article describes how to configure the GNU toolchain, so that no float or double operations are used, with the example of ARM Cortex-M. What I do? ‘Poisoning’ (!!!) the source code, forcing the gcc compiler to use software floating point operations and then catch them with the GNU linker.
Poison the float and double
One easy way is to ‘poison’ any float or double usage, using a pragma:
#pragma GCC poison float doubleAfter the ‘poison’ keyword I specify a list of identifiers which are not allowed after the occurrence of the
poison pragma
, resulting in a compiler error.
See a detailed explanation in the post here.
- SEO Powered Content & PR Distribution. Get Amplified Today.
- PlatoData.Network Vertical Generative Ai. Empower Yourself. Access Here.
- PlatoAiStream. Web3 Intelligence. Knowledge Amplified. Access Here.
- PlatoESG. Carbon, CleanTech, Energy, Environment, Solar, Waste Management. Access Here.
- PlatoHealth. Biotech and Clinical Trials Intelligence. Access Here.
- Source: https://blog.adafruit.com/2024/04/09/how-to-make-sure-no-floating-point-code-is-used/
- :is
- :not
- 288
- a
- After
- allowed
- an
- and
- Another
- any
- applications
- ARE
- AREA
- ARM
- article
- At
- avoid
- avoided
- Bad
- BE
- Blog
- CAN
- cases
- Catch
- Cause
- choice
- code
- compiler
- data
- describes
- detailed
- do
- double
- easy
- embedded
- error
- Even
- example
- explanation
- Float
- floating
- For
- forcing
- GCC
- good
- Hardware
- here
- High
- How
- How To
- HTTPS
- i
- identifiers
- in
- issues
- IT
- keyword
- least
- linker
- List
- LOOKS
- make
- max-width
- MCU
- most
- necessary
- no
- occurrence
- of
- on
- only
- Operations
- or
- performance
- plato
- Plato Data Intelligence
- PlatoData
- Point
- poison
- Post
- pragma
- Precision
- present
- process
- Read
- resulting
- should
- Size
- So
- Software
- something
- Source
- source code
- support
- sure
- that
- The
- The Source
- Them
- then
- to
- types
- Usage
- use
- used
- using
- Way..
- What
- which
- with
- zephyrnet