Re: simple example

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



This is it !

Error 1 A local variable named 'x' cannot be declared in this scope
because it would give a different meaning to 'x', which is already used
in a 'parent or current' scope to denote something else
F:\C#\ConsoleApplication1\ConsoleApplication1\Program.cs 322 14
ConsoleApplication1

This is what you get up to 2.0 (1.0 not tested ;-))

and NOT what you might expect
Error 1 The name 'x' does not exist in the current context
F:\C#\ConsoleApplication1\ConsoleApplication1\Program.cs 321 40
ConsoleApplication1

Rather than this one, with 3.5, you have "Cannot use local variable 'x'
before it is declared. The declaration of the local variable hides the field
'ConsoleApplication1.Foo.x'." which looks much closer to what you expect and
is basically correct...

So it looks messages are improved in the 3.5 compiler. Prior 3.5 I agree
that the error message is totally misleading...

So, it's really best to always mention the version you are using when it is
not current. You may want to upgrade to 3.5 (the compiler is updated but if
you don't use new 3.5 libraires, you can benefit from new language
constructs as the underlying generated IL code still targets the 2.0 CLR).

--
Patrice




.



Relevant Pages

  • Re: SOCKET problem
    ... reason for the error message is that you have a statement preceding ... the declaration; a compiler that implements C90 or C95 rather than C99 ...
    (comp.lang.c)
  • Re: Iostream
    ... > it seems when i try to compile this simple code I get an error message i ... then your compiler is installed ... int main ... by putting the 'using' directive or declaration inside the ...
    (comp.lang.cpp)
  • Re: simple example
    ... ConsoleApplication1 ... The declaration of the local variable hides the ... So it looks messages are improved in the 3.5 compiler. ... that the error message is totally misleading... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: error: expected ) before * token -- What is this ?
    ... I am getting this unhelpful error message when I try to compile ... Typedef names are treated rather oddly in C. ... Since "mytype" hasn't been declared as a typedef, the compiler doesn't ... hands and just fails to parse the declaration. ...
    (comp.lang.c)
  • Re: Question about 6.2.4 of C99
    ... compilers to reuse memory in some cases, ... muddying up the semantics and/or making the programmer work harder. ... than it would be if the declaration created and really ... I understand why the VLA rules are the way they are. ...
    (comp.std.c)