To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 5225
5224  |  5226
Subject: 
Re: Stack Overflow
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Sun, 24 Jan 1999 16:16:58 GMT
Original-From: 
Max Davies <[mdavies@cam]Spamless[.org]>
Viewed: 
893 times
  
William Sitch wrote:

...I tried to increase the stack size of the process I spawn, but the error
still exists.  I think I might be getting a compile-time stack overflow - or
something like that.  The procedure it crashes for is a leg controller, and
consists of many "if .. else if" statements.

If your code looks something like this...

if (i == 1) do001(); else
if (i == 2) do002(); else
if (i == 3) do003(); else
.
.
.
if (i == 100) do100();

...then try changing it to this:

/* Not really a loop, just so we can break */

for (;;) {
    if (i == 1) {
        do001();
        break;
    }
    if (i == 2) {
        do002();
        break;
    }
    if (i == 3) {
        do003();
        break;
    }
    .
    .
    .
    if (i == 100) {
        do100();
        break;
    }

    break;  /* Always break... this isn't really a loop */
}


...this won't be any less efficient and should resolve your compile-time stack
overflow as it doesn't nest the IF statements.

/Max



Message is in Reply To:
  Stack Overflow
 
Hi everyone: I'm trying to download a rather large chunk of code to the HandyBoard, and I'm having a problem when I exceed a certain number of instructions in a procedure I'm running. When I try to download the code, I get the error "yacc stack (...) (26 years ago, 23-Jan-99, to lugnet.robotics.handyboard)

3 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR