SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 25/01/2009, 02:07 AM   #1
Lazarus
Big Clucker
 
Join Date: Jan 2009
Posts: 123
Reputation: 0
Default Unreachable code - PAWN bug - pragma?

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.
Lazarus is offline  
Old 25/01/2009, 02:12 AM   #2
Mikep
High-roller
 
Join Date: Apr 2008
Posts: 1,042
Reputation: 2
Default Re: Unreachable code - PAWN bug - pragma?

Post the line the error is coming from.
Mikep is offline  
Old 25/01/2009, 02:18 AM   #3
Lazarus
Big Clucker
 
Join Date: Jan 2009
Posts: 123
Reputation: 0
Default Re: Unreachable code - PAWN bug - pragma?

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

pawn Code:
{
                    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.
Lazarus is offline  
Old 25/01/2009, 04:47 AM   #4
Cueball
Big Clucker
 
Join Date: Jul 2007
Posts: 109
Reputation: 14
Default Re: Unreachable code - PAWN bug - pragma?

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~
Cueball is offline  
Old 25/01/2009, 05:00 AM   #5
Lazarus
Big Clucker
 
Join Date: Jan 2009
Posts: 123
Reputation: 0
Default Re: Unreachable code - PAWN bug - pragma?

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.
Lazarus is offline  
Old 25/01/2009, 06:04 AM   #6
Cueball
Big Clucker
 
Join Date: Jul 2007
Posts: 109
Reputation: 14
Default Re: Unreachable code - PAWN bug - pragma?

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~
Cueball is offline  
Old 25/01/2009, 06:25 AM   #7
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Unreachable code - PAWN bug - pragma?

What's the point though? Why not just put it before the return?
Backwardsman97 is offline  
Old 25/01/2009, 04:10 PM   #8
Lazarus
Big Clucker
 
Join Date: Jan 2009
Posts: 123
Reputation: 0
Default Re: Unreachable code - PAWN bug - pragma?

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.
Lazarus is offline  
Old 25/01/2009, 04:14 PM   #9
yom
Gangsta
 
Join Date: Jul 2006
Posts: 988
Reputation: 6
Default Re: Unreachable code - PAWN bug - pragma?

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.
yom is offline  
Old 25/01/2009, 06:16 PM   #10
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,464
Reputation: 382
Default Re: Unreachable code - PAWN bug - pragma?

pawn Code:
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.
Finn is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With this Unreachable Code ihatetn931 Help Archive 6 06/01/2010 01:15 PM
[HELP]Unreachable code Michelman Help Archive 3 06/12/2009 07:25 PM
unreachable code Typhome Help Archive 3 15/08/2009 08:04 PM
[Help] Unreachable Code cozza123456 Help Archive 4 14/08/2009 02:36 PM
unreachable code???? mike_l Help Archive 4 03/04/2009 10:16 AM


All times are GMT. The time now is 05:40 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.