??? 11/11/11 13:49 Read: times |
#184634 - At the very least use static for one-time initialized locals Responding to: ???'s previous message |
main() is living for the full time of the application.
So why do you have large local variables in main(), that the compiler will then have to fight to try to convert into global (but nameless) variables just since the used processor do not support any hardware stack that can handle them? I assume you are not going to call main() recursively, so just making them "static" makes a difference to the compiler/linker by telling it that the initialization can happen once - and at a time the compiler/linkers thinks is best - instead of having to happen after main() is reached but before the first C statement inside main() is run. You are not programming a PC. You do not have access to 10kB or 1MB of stack space. The stack space available is just about enough to handle interrupts, and to handle the return address when returning back from a not too long chain of function calls. Do you have any project management that have decided that you must not have global variables, making you "cheat" by having local variables in main() and then let the rest of the program access them through pointers? |