delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/23/18:40:47

From: Charles Terry <cterry AT plinet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: "jump to case label" message; please help me!
Date: Mon, 23 Mar 1998 07:47:39 -0800
Organization: All USENET -- http://www.Supernews.com
Lines: 36
Message-ID: <3516841B.2112@plinet.com>
References: <35134F49 DOT C51C6867 AT geocities DOT com> <351398AC DOT 504F AT acadia DOT net> <3513EC92 DOT AEA5E9A1 AT geocities DOT com>
NNTP-Posting-Host: 21382 AT 207 DOT 174 DOT 3 DOT 209
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> > Dan Chak wrote:
> > >
> > > I have the following code in a program of mine which (to me) seems to be
> > > harmless.  However, I get an error with DJGPP that says "Error: Jump to
> > > case label" for the line that reads "case 3:".  Can anyone help me
> > > figure out why??
> > >
> > >    int choice;
> > >    do {
> > >       choice = mainMenu->update();
> > >       switch (choice) {
> > >          case 2:
<snipped>
> > >             choice = 0;
> > >             break;
> > >          case 3:
> > >             delete mainMenu;
> > >             delay(2);
> > >             break;
> > >       }
> > >    } while (!choice);
> > >
> > > Thanks,
> > > Dan Chak
> > > chakster AT geocities DOT com

I think your problem might be that you are changing
your switch control variable in the middle of the
switch.
Havn't tried it but maybe use a holding variable
instead of choice in case 2 then assign choice to it
outside of the switch statement.  I would agree that
the code as is should work but maybe the compiler optimizations
are producing a weird result.

Charles Terry

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019