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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux