HI, i am writing a program in which there are many do-while loops one inside the other... when i try compile this program... it gives me a error stating.."'{' scope stack overflow.." it point to braces i have used in DO-WHILE an IF statement... plss help me to solve this problem... THANKS...
actully i m a fresher in an EMBEDDED job.... CURRENTLY I M WORKING IN A PROJECT WHERE IN THERE IS NEED OF MULTIFUNCTIONING OF 4 PUSH BUTTON SWITCH..... ALSO THERE IS A NEED IS TO LATCH THE CONTENT OF 7 SEG UNTIL NEXT BUTTON IS PRESSED OR UNTIL THE POWER IS OFF....THEREFORE THERE IS NEED OF WHILE(1) LOOP AT EACH STAGE... THERE IS NEED TO DISPLAYED SEVERAL NO.OF PAGES AT EACH PRESSED BUTTON... AT EACH STAGE ANY OF 4 BUTTON CAN BE PRESSED...
DON'T SHOUT!!
No, there is no inherent need of a while(1) loop at each stage!
I suggest you look into using a Finite State Machine (FSM) aka "Finite State Automaton" (plural: Automata) or just "State Machine"
www.8052.com/.../171492
www.8052.com/.../47505
State Machines for Event-Driven SystemsState machines are perhaps the most effective method for developing robust event-driven code for embedded systems." by Miro Samek: www.netrino.com/.../State-Machines-Event-Driven-Systems
Coding State Machines in C and C++"An overview of state-machine fundamentals and guidelines for coding state machines in C or C++." by Miro Samek: www.netrino.com/.../Coding-State-Machines
This Whitepaper (with accompanying source code) gives a very good example of applying a State Machine design: www.visualgps.net/.../NMEAParser.html
Has moved to: www.barrgroup.com/.../Coding-State-Machines
Similarly: www.barrgroup.com/.../State-Machines-Event-Driven-Systems
So then there really was a good reason for me to ask you exactly why you thought you needed so very indented code.
for(;;) { key = check_keys(); switch (state) { ... case STATE_MAINMENU: if (key == ENTER) { state = menuchoices[curr_menu_item]; } break; ... case STATE_WAITINPUT: if (key == ESC) { state = STATE_MAINMENU: } else { ... } break; ... } }
You want your main loop to iterate often, so it can check important global states. That means that the main loop should try to avoid to contain subroutines (or nested loops) that will take any significant amount of time.
We had someone do a firmware enhancement for us and he put in some finite state machines.
Trouble was he was so engrossed with them at the individual level that he neglected to include suitable protection (like task locking) on the interaction between them.
Careful. They are not the cure all. You still need good understanding of ALL aspects.
Good point.
There are no safe concepts that can't be abused by someone willing to try.
Innnndeeeeeeeeedddddd.
ohh gud 1..... thanks a lot bro.... i'll try to modify the code... ONCE AGAIN THANK U very much..
Aren't your m8 h jameel telling you this? Maybe your m8 want you to fail?
MULTIFUNCTIONING OF 4 PUSH BUTTON SWITCH..... ALSO THERE IS A NEED IS TO LATCH THE CONTENT OF 7 SEG UNTIL NEXT BUTTON IS PRESSED
Did you get desperate? that is no excuse for starting to shout
I'll bet you dollars to doughnuts that I could code the above with proper indentions and not need to tab any line more than 3 times.
your concept (if it can even be called that) s totally screwed up.
Erik
i m not shouting bro.... writing msg with CAPS on doesn't mean shouting... i guess.. as far as betting is concerned.... after completion of my work i'll talk to u on this...
Yes, it most certainly does!!
Yes, writing with CAPS is a strengthening of the text that has been commonly agreed to mean shouting when used on the net.
Just as Pavlov's dog was conditioned to start to salivate just on hearing the ringing of a bell, experienced web visitors are conditioned to react on all caps just as if the other person was close by and actually did shout. Net result? Lots of people will directly close the thread and ignore the shouter, just as we would react if someone outside would without motive start to shout at us.
Whatever you do - do not shout in threads unless there is a very specific reason to. And then consider just shouting a single word or at a maximum a single sentence. Shouting a full post screams another message: Immature child or fool. Why? Well, immature childs and fools are the ones who have not picked up the normal social conventions. A child because he/she is too young. A fool. A fool because the mental operation isn't as it should be. So in the end - shouting on the net is not a win-win solution to a problem.
writing msg with CAPS on doesn't mean shouting
It is purely a matter of convention (although a convention established over decades of use, so you'd do well to observe it)