c - avr-gcc never returning main optimalization -
somewhere read if never return main()
loop, can spare ~66 bytes compiler switch in avr-gcc
, couldn't find site anymore.
this embedded:
main() { while(1) { // stuff } }
for gcc
can use special attribute indicate function not return:
int main() __attribute__ ((noreturn)) { (;;) { // stuff } __builtin_unreachable (); }
optionally can add __builtin_unreachable ();
indicate part of code can never reached.
although in cases recognised optimisation flags, without such while(1)
can generate more code for(;;)
.
Comments
Post a Comment