Thread: setjmp/longjmp
View Single Post
  #4   Spotlight this post!  
Unread 25-01-2007, 08:24
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: setjmp/longjmp

Generally speaking, labels and goto's (the C equivalent) are strongly discouraged. They complicate code and remove structure that belongs in if's, while's, and for's. Only use this if you absolutely must and all other solutions are totally unacceptable. (And even then, I would stick to the other solutions.)

As for your problem specifically, the state machines are long but the individual sections are short, and all the code is well commented. There's no other way to do those, really. They're long processes with lots of steps. (This is for both camera.c and camera_menu.c) The only other way I can think of to do it would be to implement each step as a function and have a function pointer indicate the current step, but that has its own issues (eg, How do you check valid values?).

Also remember that since the processor is not multithreaded, so there is no "giving up" the CPU.

If you don't like the switch(), you could use the preprocessor to create "more friendly" syntax.