Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Per Westermark
11/11/11 06:49
Read: 474 times
Sweden


 
#184634 - At the very least use static for one-time initialized locals
Responding to: Lukas Valecky'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?

List of 39 messages in thread
TopicAuthorDate
Keil problem...      Lukas Valecky      11/10/11 03:53      
   Kel support      Per Westermark      11/10/11 05:41      
      Keil support      Erik Malund      11/10/11 06:49      
         Reward for finding bug      Bert Van Den Berg      11/10/11 10:27      
            been tried      Erik Malund      11/10/11 10:51      
               public bug tracker      Maarten Brock      11/11/11 01:09      
                  It's not a KEIL-specific problem ...      Richard Erlacher      11/21/11 11:18      
                     not really      Maarten Brock      11/22/11 03:56      
                        It's those "snapshots" that I meant      Richard Erlacher      11/22/11 07:49      
                           Not true        Per Westermark      11/22/11 08:05      
                              Remember, where you sit determines what you see      Richard Erlacher      11/22/11 22:18      
                                 Concept      Per Westermark      11/23/11 02:11      
                                 I do not ...      Erik Malund      11/23/11 07:04      
                                    Comfort contra mobile phone      Per Westermark      11/23/11 08:30      
                                       Where you sit determines what you see ...      Richard Erlacher      11/24/11 00:58      
                                          You are still assuming you know what other people think/do        Per Westermark      11/24/11 02:49      
                                             You've overlooked the most basic fact ...      Richard Erlacher      11/24/11 16:31      
                                                Unuseful toy?      Per Westermark      11/24/11 17:18      
                                                   Once again, you've missed the point ...      Richard Erlacher      11/26/11 08:46      
                                                      Look for progress, instead of just looking back at history      Per Westermark      11/26/11 10:36      
                                                         are you that lucky?      Erik Malund      11/26/11 10:46      
                                                            Yes      Per Westermark      11/26/11 11:17      
                                                         Consider my position      Richard Erlacher      11/27/11 00:26      
      keil update      Lukas Valecky      11/10/11 07:47      
         auto variables      Per Westermark      11/10/11 08:24      
   Global Variable Initiaization      Michael Karas      11/10/11 06:40      
   just curious      Erik Malund      11/10/11 07:53      
      Always good to hide black-box data in structs      Per Westermark      11/10/11 08:19      
      Initialising array inside struct      Oliver Sedlacek      11/11/11 01:48      
         not necessarily      Jan Waclawek      11/11/11 02:10      
      Library      Lukas Valecky      11/11/11 05:00      
   New facts...      Lukas Valecky      11/11/11 06:35      
      At the very least use static for one-time initialized locals      Per Westermark      11/11/11 06:49      
         it works! thanks...      Lukas Valecky      11/15/11 11:36      
            Look at code in Debugger. It will tell all.      Michael Karas      11/15/11 12:19      
               It's called "Overlaying"      Andy Neil      11/15/11 15:00      
                  Optimization      Per Westermark      11/15/11 15:34      
      are you sure ...      Erik Malund      11/11/11 06:51      
   Thanks...      Lukas Valecky      11/21/11 10:55      

Back to Subject List