Unreachable code - PAWN bug - pragma?
#1

PAWN produces an "unreachable code" warning if anything is written after a return within the same bracket compartment. However, I'm using the "goto" function (basically lets you jump to a certain line in the code), and pawn still says it's unreachable. To make sure, I've tested it and it works fine.

What's the easiest way to stop this warning? I can't find a pragma function for that specific warning in the pawn-lang.pdf.

Edited for spelling.
Reply
#2

Post the line the error is coming from.
Reply
#3

You've been given all the information you need. None the less, enjoy:

pawn Код:
{
                    goto next;
                }
            }
        }
        return 1;

next: // <= warning here
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][cjoin] == true)
            {
Please note that it isn't the line causing it, that's the return.
Reply
#4

No, we hadn't been given all the information we needed.

You can't have code after you return something, regardless of whether you skipped to a certain point before reching the return. If applicable, add the code under 'next' into a function, or else put it at 'goto next'.

And no, it's not a PAWN bug

~Cueball~
Reply
#5

Out of curiosity... what piece of information weren't you given :P?

And, correct me if I'm wrong, but that is a warning saying that the piece of code in that position wont be able to run in the server. Unreachable. As it is able to run, it's mistakenly giving me warning. When a program makes a mistake, it's formally known as a bug.
Reply
#6

We wanted to see in what context you were getting the message

This would be happening because you have probably placed the goto statement inside a conditional and the compiler treats these differently to just stand-alone code. Try making the conditional (if there is one) inversed (if it's currently true, make it false, vice versa), and then let us know what happens.

Sorry if I sounded like a jerk, I was just trying to let you know.

And I know what a bug is, cheers.

~Cueball~
Reply
#7

What's the point though? Why not just put it before the return?
Reply
#8

Because I need it to stop the code there under some none-else circumstances.
I'm not here looking for a code fix, the code is fine (hence the reason I'm calling it a "bug"). I'm just here looking for a "pragma" or else to stop the warning.
Reply
#9

We don't see enough of your code.. try break;

No, your code isn't fine, it's obvious that you can't do anything under return.
Reply
#10

pawn Код:
if(ThisIsTrue) // <- Do you have an if-statement here?
}
  {
    {
      goto next;
    }
  }
}
else return 1; // Try adding 'else' over here if this is if-statement
next:
Try that, maybe it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)