----- Ursprüngliche Nachricht -----
Von: Peter Bigot
Gesendet am: 22 Feb 2012 16:24:20
> I believe the number of people wanting to put main
> into an archive is smaller than the number of people trying to write
> code for the value-line chips who could be impacted by such a change,
I agree. "main" is special, as it is the starting point of the program.
It makes not much sense to put main into an archive and build a program with it.
Every applicaiton that's worth being linked (means: that differs from an
existing
already compiled and linked binary) will usually have a different main.
Since main is the start of the dependency tree (not counting the
startup code), any application linked with a static main will also
link the exactly same set of other codes, resulting in the same application.
An exception to this would be an applicaiton that is self-configuring at
runtime based
project-specific initialized variables (not defines!)
Since such an applicaiton would have to include all the code for an ypossible
ocnfiguration,
and will have to check for the required parts at runtime, this will be a waste
of flash and
ram space and processing power and is therefore not a suitable approach for a
microcontroller.
If a library funciton is needed that sets up the system, then name it 'init()'
and call it from
the project-specific main. :)
Sure there is the very specific case that you want to link the same applicaiton
but with a different
e.g. putchar() method.
In this very specific case, including a
main(){init();}
line to the project surely won't hurt.
p.s.: the problem with local variables in main (which you mentioned previously
in this thread)
is not only limited to debugger problems. These variables are effectively
static (unless the
compiler can optimize them to register variables and discard them when no
longer required).
If placed on stack, they require permanent stack space, but are not recognized
by
the linker when linking the ram space. So you won't get a linker warning when
you use
more variables than you have ram.
In TI E2E forum I suggested declaring local variables in main as static, so the
stack size test in the linker and the stack overflow warning in the debugger
still work.
And you still keep the local scope. (in case of counter variables, they might
be declared
as register variables, but I don't know whether this works in CCS and IAR, so I
don't
mention this)
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users