This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

When to use if-if, else-if, switch, goto and local scope vars?


Hello!


Im  programming an avr microcontroller in pure C at the moment and am close to
run out of memory and cycles. So I did  some  research  on  optimization.  The
problem is there are so many articles and hints that do not state the same and
do not clearly point out what is valid for pure C. So I'd like to know:

- when to use switch instead of else-if statments
- how many cases there have to be for switch to be better than else-if?
- is an if-if statement better  than  if-else-if  or  switch  when  it  is  an
exclusive decission?
- is it better to nest switch statement or use else-if instead of nesting?
- does it save RAM when I define variables in the innermost scope possible?
- when does it help writing out loops?
- should I concider using banned goto instructions for microcontrollers?

Thanks for Your answers.
Lynx



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]