#22 variable scoping problem

compiler
closed-fixed
NXC (53)
5
2007-09-26
2007-08-09
Rupert
No

When a variable of the same name is declared multiple times, but with different scope, the code apparently compiles to NBC, but the variables get the same name, and end up interfering at the NBC compilation stage.

Example: This code wont compile
task main() {
if(1){
int testvar=0;
NumOut(0,LCD_LINE1,testvar,1);
Wait(5000);
}
if(1){
int testvar=0;
NumOut(0,LCD_LINE1,testvar,1);
Wait(5000);
}

}

It gives the error
Line 8: Error: Duplicate identifier __main_testvar_001

This is with version 1.0.1.32

Thanks
--rupert b

Discussion

  • John Hansen

    John Hansen - 2007-09-26
    • status: open --> closed-fixed
     
  • John Hansen

    John Hansen - 2007-09-26

    Logged In: YES
    user_id=661666
    Originator: NO

    This bug is fixed in beta 33 (http://bricxcc.sourceforge.net/test_release.zip). The official beta 33 release will be available by Sept 30, 2007.

    John Hansen

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks