When to use if-if, else-if, switch, goto and local scope vars?
lynx.abraxas@freenet.de
lynx.abraxas@freenet.de
Sun Sep 23 12:41:00 GMT 2007
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
More information about the Gcc-help
mailing list