Where did those warnings come from?
#1

Hello
I've made a stock that worked perfectly untill I made another stock (that has nothing to do with this one).
I get those warnings (which I have never seen before,btw) when I compile:
pawn Код:
(417) : warning 206: redundant test: constant expression is non-zero
(418) : warning 206: redundant test: constant expression is non-zero
(419) : warning 206: redundant test: constant expression is non-zero
(420) : warning 206: redundant test: constant expression is non-zero
(421) : warning 206: redundant test: constant expression is non-zero
(422) : warning 206: redundant test: constant expression is non-zero
(423) : warning 206: redundant test: constant expression is non-zero
(426) : warning 206: redundant test: constant expression is non-zero
(427) : warning 206: redundant test: constant expression is non-zero
(428) : warning 206: redundant test: constant expression is non-zero
(429) : warning 206: redundant test: constant expression is non-zero
(430) : warning 206: redundant test: constant expression is non-zero
For those lines:
pawn Код:
stock SetPlayerTeamFromClass(playerid,classid)
{
    if (classid == X,X,X) { gTeam[playerid] = TEAM_X; }
    else if (classid == Y,Y,Y,Y,Y,Y,Y,Y) { gTeam[playerid] = TEAM_Y; }
    else if (classid == Z,Z,Z) { gTeam[playerid] = TEAM_Z; }
    else if (classid == A,A,A,A,A,A,A,A) { gTeam[playerid] = TEAM_A; }
    else if (classid == B,B,B,B) { gTeam[playerid] = TEAM_B; }
    else if (classid == C,C) { gTeam[playerid] = TEAM_C; }
    else if (classid == D,D,D,D,D) { gTeam[playerid] = TEAM_D; }
    else if (classid == E) { gTeam[playerid] = TEAM_E; }
    else if (classid == F) { gTeam[playerid] = TEAM_F; }
    else if (classid == G,G,G,G,G,G,G) { gTeam[playerid] = TEAM_G; }
    else if (classid == H,H,H,H,H,H) { gTeam[playerid] = TEAM_H; }
    else if (classid == I,I,I) { gTeam[playerid] = TEAM_I; }
    else if (classid == J,J,J) { gTeam[playerid] = TEAM_J; }
    else if (classid == K,K,K) { gTeam[playerid] = TEAM_K; }
    return 1;
}
(I censured the classes and teams,sorry)
I get the warnings for all lines exept arguments E and F.
Please help me
Thanks
Reply
#2

hey man do CTRL+G and type the line no and find simple
>>(417) : warning 206: redundant test: constant expression is non-zero
>>(41 : warning 206: redundant test: constant expression is non-zero
>>(419) : warning 206: redundant test: constant expression is non-zero
>>(420) : warning 206: redundant test: constant expression is non-zero
>>(421) : warning 206: redundant test: constant expression is non-zero
>>(422) : warning 206: redundant test: constant expression is non-zero
>>(423) : warning 206: redundant test: constant expression is non-zero
>>(426) : warning 206: redundant test: constant expression is non-zero
>>(427) : warning 206: redundant test: constant expression is non-zero
>>(42 : warning 206: redundant test: constant expression is non-zero
>>(429) : warning 206: redundant test: constant expression is non-zero
>>(430) : warning 206: redundant test: constant expression is non-zero
Reply
#3

Quote:
Originally Posted by cs_master
Посмотреть сообщение
hey man do CTRL+G and type the line no and find simple
>>(417) : warning 206: redundant test: constant expression is non-zero
>>(41 : warning 206: redundant test: constant expression is non-zero
>>(419) : warning 206: redundant test: constant expression is non-zero
>>(420) : warning 206: redundant test: constant expression is non-zero
>>(421) : warning 206: redundant test: constant expression is non-zero
>>(422) : warning 206: redundant test: constant expression is non-zero
>>(423) : warning 206: redundant test: constant expression is non-zero
>>(426) : warning 206: redundant test: constant expression is non-zero
>>(427) : warning 206: redundant test: constant expression is non-zero
>>(42 : warning 206: redundant test: constant expression is non-zero
>>(429) : warning 206: redundant test: constant expression is non-zero
>>(430) : warning 206: redundant test: constant expression is non-zero
English Please..
Sorry I just couldn't understand what you were saying (espically the last part)
Reply
#4

i say check lines and solve
Reply
#5

pawn Код:
stock SetPlayerTeamFromClass(playerid,classid)
{
    if (classid == X) { gTeam[playerid] = TEAM_X; }
    else if (classid == Y) { gTeam[playerid] = TEAM_Y; }
    else if (classid == Z) { gTeam[playerid] = TEAM_Z; }
    else if (classid == A) { gTeam[playerid] = TEAM_A; }
    else if (classid == B) { gTeam[playerid] = TEAM_B; }
    else if (classid == C) { gTeam[playerid] = TEAM_C; }
    else if (classid == D) { gTeam[playerid] = TEAM_D; }
    else if (classid == E) { gTeam[playerid] = TEAM_E; }
    else if (classid == F) { gTeam[playerid] = TEAM_F; }
    else if (classid == G) { gTeam[playerid] = TEAM_G; }
    else if (classid == H) { gTeam[playerid] = TEAM_H; }
    else if (classid == I) { gTeam[playerid] = TEAM_I; }
    else if (classid == J) { gTeam[playerid] = TEAM_J; }
    else if (classid == K) { gTeam[playerid] = TEAM_K; }
    return 1;
}
Reply
#6

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
pawn Код:
stock SetPlayerTeamFromClass(playerid,classid)
{
    if (classid == X) { gTeam[playerid] = TEAM_X; }
    else if (classid == Y) { gTeam[playerid] = TEAM_Y; }
    else if (classid == Z) { gTeam[playerid] = TEAM_Z; }
    else if (classid == A) { gTeam[playerid] = TEAM_A; }
    else if (classid == B) { gTeam[playerid] = TEAM_B; }
    else if (classid == C) { gTeam[playerid] = TEAM_C; }
    else if (classid == D) { gTeam[playerid] = TEAM_D; }
    else if (classid == E) { gTeam[playerid] = TEAM_E; }
    else if (classid == F) { gTeam[playerid] = TEAM_F; }
    else if (classid == G) { gTeam[playerid] = TEAM_G; }
    else if (classid == H) { gTeam[playerid] = TEAM_H; }
    else if (classid == I) { gTeam[playerid] = TEAM_I; }
    else if (classid == J) { gTeam[playerid] = TEAM_J; }
    else if (classid == K) { gTeam[playerid] = TEAM_K; }
    return 1;
}
I thank about that but I have noticed something:
1)It never gave me those warnings before I added another stock
2)And if for example I have 5 arguments of X? What do I do then?
Reply
#7

You in 1variable saving 5values?
Reply
#8

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
You in 1variable saving 5values?
Its not variables,its just the classid with is already defined
For example:
pawn Код:
if (classid == 1,2,3,4,5,6) { gTeam[playerid] = TEAM_X; }
Get it?
Reply
#9

pawn Код:
if (classid == 0 || classid == 1 || classid == 2 || classid == 4) { do; }
More efficent:
pawn Код:
switch (classid)
{
    case 0, 1, 2, 4: // classid is 0-4
}
Reply
#10

Quote:
Originally Posted by Montserrat
Посмотреть сообщение
Its not variables,its just the classid with is already defined
For example:
pawn Код:
if (classid == 1,2,3,4,5,6) { gTeam[playerid] = TEAM_X; }
Get it?
You can't do that in an if statement.

pawn Код:
switch(classid) {
   case 1, 2, 3, 4, 5, 6: { // or 1...6
      gTeam[playerid] = TEAM_X;
   }
}
If you still want to use an if statement for it, you'd have to do:

pawn Код:
if(1 <= classid <= 6) gTeam[playerid] = TEAM_X; // If this is the right operator
// or
if(classid == 1 || classid == 2 || classid == 3 || classid == 4 || classid == 5 || classid == 6) gTeam[playerid] = TEAM_X;
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)