I'm building a 16 state FSM on a PIC18 with C18. I'm considering having each state as its own function which jumps to and gets jumped by other states. I'm tempted to just write a branch cases of "state##();"s at the end of each state to determine where the program should go, but I'm thinking this would die pretty quickly since the compiler likely expects this to return, not branch forever; the stack on my microcontroller would quickly fill up and eventually overflow.
Is C18 smart enough to know that my function call will never return back and replace the instruction with a GOTO/JMP instead of a CALL/BRANCH accordingly? I'm aware GOTO exists in C (and is usually strongly advised against for readability reasons) but I can't think of more appropriate reason to use it than here. I'm aware that I can just force it to goto with an _asm _endasm block, but I'll save myself the trouble if it's not necessary. What would be the best way in C to say to go to a function and never come back?
Naturally, all help is appreciated