www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/07/08:44:17

Message-ID: <37AA4BFB.10A451EC@lan.tjhsst.edu>
Date: Thu, 05 Aug 1999 22:44:11 -0400
From: Moogla <ngoldber AT lan DOT tjhsst DOT edu>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Re: interesting error
References: <NMJEMAMNAGHLAAAA AT mailcity DOT com>
Reply-To: djgpp AT delorie DOT com


Brian Ronk wrote:

> I got an error in a switch statement: case bypasses local variable initialization.  any ideas what it is and how to fix?
>
> Brian Ronk

interesting error? This is a standard ANSI <B>C</B> (i think) violation.

You never, ever, ever, declare a variable in one case and use it in another. Keep the declarations out of the switch
statement, or make them active only from case X: to the break;

If you think you've done that, just check, make sure you're not reusing possibly active variable names. And check to make
sure all your case statements have their appropriate breaks (so there's no unintended fall through that gcc happened to get
annoyed over).
for safety, do this
case X:
{
//code
break;
}

So that there's no variable leakage possible
If you post your code, I think we can find the problem, and better suggest remedy tho.

moogla


- Raw text -


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