www.digitalmars.com         C & C++   DMDScript  

c++ - porting problem

reply Andrew McKinlay <mckinlay axonsoft.com> writes:
Here is a simplified version of what's causing me trouble:

	if (bool b2 = b)
		{
		char* p = "hello";
		}
	else
		{
		char* p = "world";
		}

gives: Error 'p' is already defined

However, this is fine:

	if (b)
		{
		char* p = "hello";
		}
	else
		{
		char* p = "world";
		}

I haven't had a problem with this on VC++ or GCC. Obviously, 
the code could (should?) be rewritten, but I'm porting a 
large program and I'd rather not have to. I'm curious what 
the "correct" behaviour is.

andrew
Dec 24 2004
parent "Walter" <newshound digitalmars.com> writes:
I'll add it to the problem queue. Thanks!
Dec 27 2004