[En-Nut-Discussion] Problems using global variables and/or floating point numbers on Nut/Os (using ethernut 5)

Nathan Moore nategoose at gmail.com
Wed May 30 16:35:45 CEST 2012


On Wed, May 30, 2012 at 8:50 AM, Ole Reinhardt <ole.reinhardt at embedded-it.de
> wrote:

> Hi,
>
> > Unfortunately, the global variables is a part of a high speed
> > optimization program I use. And I do not have the possibility to
> > change it.
> >
> > Any idea if the 7000-20000 global double values will be a problem for
> > the ethernut board?
>
> In general this should be ok. They will just make the binary lager.


If the global variable is initialized to 0, 0.0, or NULL (all bits 0) or not
initialized at all (and not part of a struct or array that has members that
don't meet this) then it should be part of the .bss (blank space
segment) and not add to the binary size.

If the global variable does not meet this requirement then an initialization
value for it must be stored in the .data section of the binary which
increases
the binary size.

If you try to be sneaky and not initialize global variables but then later
set
their values in code you'll end up with either the same size or a larger
binary
than if you had just initialized the global variables (unless you are
really sneaky
and use good compression on your data).  This is because the code to load
the .data section initialization values is included by the linker in the
binary already
so you might as well just let it do its job.


Nathan



More information about the En-Nut-Discussion mailing list