delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/06/08:06:37

Date: Thu, 5 Aug 1999 20:08:21 -0400
Message-Id: <199908060008.UAA10923@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <NMJEMAMNAGHLAAAA@mailcity.com> (rithe@mailcity.com)
Subject: Re: interesting error
References: <NMJEMAMNAGHLAAAA AT mailcity DOT com>
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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

Instead of this:

	switch (x) {
	  case 3:
	    int x = 0;
	}

do this:

	int x;
	switch (x) {
	  case 3:
	    x = 0;
	}

or sometimes this:

	switch (x) {
	  case 3:
	    int x;
	    x = 0;
	}

or even this:

	switch (x) {
	  case 3:
	    {
	      int x = 0;
	    }
	}

- Raw text -


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