Problem Symbol Already Defined
#1

I have an swith with different 'cases'. I defined some variables under one case and if i define same variables under another case it say 'symbol already defined' for some of theese variables.

Код:
new string[128], banned, resultline[512], BanTime, Name[24], BanIP[24];
			new BanBy[24], BanReason[24], BanDate[24], BanExpire[24], BanCode[24], time[6][24];
			new y,m,d,y2,m2,d2;
			new h,mi,s,h2,mi2,s2;
I get error for:

Код:
new string[128], banned, resultline[512], BanTime, Name[24], BanIP[24];
			new BanBy[24], BanReason[24], BanDate[24], BanExpire[24], BanCode[24], time[6][24];
Because theese variables are defined under another case but i don't get any error for:

Код:
new y,m,d,y2,m2,d2;
			new h,mi,s,h2,mi2,s2;
Can someone explain me why?
Reply
#2

If you're using them above, there's no need to define them again. Just delete the variables it gives the symbol already defined.
Reply
#3

That i did for:

Код:
new string[128], banned, resultline[512], BanTime, Name[24], BanIP[24];
			new BanBy[24], BanReason[24], BanDate[24], BanExpire[24], BanCode[24], time[6][24];
But not for:

Код:
new y,m,d,y2,m2,d2;
			new h,mi,s,h2,mi2,s2;
y, m, d, y2, m2.... still be defined above and i don't get any error with symbol already defined and can't understand why i don't get error for all variables that are already defined ...
Reply
#4

Maybe because the first variables are a lot. If you delete them, you may got the rest of the errors. This is something compiler does frequently. Anyway, define them at the start and delete the rest, it is no need.
Reply
#5

I did it too but if i delete theese:
Код:
new y,m,d,y2,m2,d2;
new h,mi,s,h2,mi2,s2;
From the 2nd 'case' it say that theese symbols aren't defined, but theese are in first case.
Reply
#6

pawn Код:
// This is the start.
{
    new
        x
    ;
    // define the rest here, it is just an example
    switch( x )
    {
        case 0: // Do something
        case 1: // Do something else
    }
    // Rest of code
Reply
#7

Yea that is how i did it finally but I was thinking why if i have two variable defined in two difference case i get error for symbol already defined for only one variable ...
Ex:
Код:
switch( x )
{
         case 0:
         {
                  new x, y;
         }
         case 1:
         {
                  new x, y:
         }
}
And got error only for Y in 2nd case. That's how was my problem, fixed it moving definition of variables before switch but i didn't understant why i got this error :d
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)