SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/02/2012, 01:29 AM   #1
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 17,542
Reputation: 2438
Default YSI Errors and Warnings

Introduction

YSI uses A LOT of macros to make things easier to write. The downside to this is that it can make errors and warnings very hard to interpret as they will refer to code after macro replacement is done. This guide should help you to translate the given errors to the real errors.

I will add more as I become aware of them.

Errors and Warnings

1)
  • Code

pawn Code:
// Alternate:
//CMD:kickplayer(playerid, params[])
YCMD:kickplayer(playerid, params[], help) // Warning line.
{
    // Some code here.
}
  • Problem

Code:
<path>\errors.pwn(11) : warning 203: symbol is never used: "kickplayer"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
  • Solution

You didn't include "YSI\y_commands". Commands are never explicitly called anywhere in code, so the compiler needs to be told that they will be called eventually.

pawn Code:
#include <YSI\y_commands>

2)
  • Code

pawn Code:
timer X() // Error line.
{
}
  • Problem

Code:
<path>\errors.pwn(3) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
  • Solution

In this case the error message is fairly descriptive. It IS an invalid declaration - there is no delay specified for the timer.

pawn Code:
timer X[100]()
{
}

3)
  • Code

pawn Code:
X[100]() // Error line.
{
}
  • Problem

Code:
<path>\errors.pwn(3) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
  • Solution

Very similar problem to the last one, only this time missing the "timer" keyword instead of the time.

pawn Code:
timer X[100]()
{
}

4)
  • Code

pawn Code:
timer X[100](arr[]) // Error line.
{
}
  • Problem

Code:
<path>\errors.pwn(3) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
  • Solution

You have the syntax right with both "timer" and the time, but you STILL get an invalid declaration. This is actually another handy error telling you the truth. All arrays on "timer", "global" and "remotefunc" functions MUST be followed by their length. Strings do NOT need their length, but instead MUST be declared as "string:", otherwise the compiler can't tell the two apart.

pawn Code:
timer X[100](arr[], size)
{
}

pawn Code:
timer X[100](string:arr[])
{
}

5)
  • Code

pawn Code:
main()
{
    new
        Iterator:x<100>; // Warning line.
    foreach (new i : x)
    {
    }
}
  • Problem

Code:
<path>\errors.pwn(6) : warning 203: symbol is never used: "x@YSII_Cg"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
  • Solution

This is one of the slightly more esoteric warning messages. Iterators compile to TWO variables - an array of data and a size. The data array is called "<name>@YSII_Ag", and the size variable is called "<name>@YSII_Cg". If you get a warning that the size variable is never used, it means the size is never modified, which means nothing is ever added to, or removed from the iterator. If this is the case then your iterator is always empty and thus pointless. If you get a message that "<name>@YSII_Ag" (the data array) is also never used, then the iterator is never used at all, even in a "foreach" loop.

pawn Code:
main()
{
    new
        Iterator:x<100>;
    Iter_Add(x, 10);
    foreach (new i : x)
    {
    }
}

6)
  • Code

pawn Code:
main()
{
    new
        Iterator:x<100>;
    Iter_Add(x, 10);
    foreach (i : x) // Error line.
    {
    }
}
  • Problem

Code:
<path>\errors.pwn(7) : error 017: undefined symbol "i"
<path>\errors.pwn(7) : warning 206: redundant test: constant expression is non-zero
<path>\errors.pwn(7) : error 017: undefined symbol "i"
<path>\errors.pwn(7) : warning 221: label name "_Y_ITER_C0" shadows tag name
<path>\errors.pwn(7) : warning 225: unreachable code
<path>\errors.pwn(7) : error 017: undefined symbol "i"
<path>\errors.pwn(7) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
  • Solution

Here only the first error is important, all the others are caused by the first one. They can be confusing as they expose some of the internals of "y_iterate", but just ignore them and fix the first error (same as ever).

pawn Code:
main()
{
    new
        Iterator:x<100>;
    Iter_Add(x, 10);
    foreach (new i : x)
    {
    }
}

7)
  • Problem

The compiler hangs.
  • Solution

There are a number of causes of this, commonly a macro expanding to too much code. If you have a "foreign", "global", "remotefunc" or "timer" declaration which is very big, like:

pawn Code:
timer MyTimer[1000](playerid, string:str[], arr[], size, string:other[], string:final[])
{
}

The above code WILL hang the compiler. On its own it is not a long line - very short relative to the 511 character maximum, but as stated earlier YSI uses a lot of macros and this expands to a long line of code (efficient, but long). The issue is intermediate stages - the code is expanded to very long code, then reduced to only slightly longer code. Try shortening the line.

pawn Code:
timer MyTimer[1000](p,string:s[],a[],c,string:o[],string:f[])
{
}

That will compile fine. If the compiler still hangs (and you've confirmed which function is the problem by commenting out all others), then you may have to resort to using alternate methods such as basic "forward"/"public" timers. The code generated by "foreign" and "global" is so long that it had to be split in to two parts - hence why the two keywords were made to mirror "forward" and "public".

8)
  • Code

pawn Code:
main()
{
    inline Func(arr[]) // Error line.
    {
    }
}
  • Problem

Code:
<path>\errors.pwn(7) : error 009: invalid array size (negative, zero or out of bounds)
<path>\errors.pwn(7) : error 001: expected token: ")", but found ";"
<path>\errors.pwn(7) : error 036: empty statement
<path>\errors.pwn(7) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
  • Solution

This is actually a similar problem to number 4, but with different symptoms. Unfortunately inline functions cannot have arrays at all, even when followed by their size. If you do try include the size you will get an additional:

Code:
<path>\errors.pwn(7) : warning 215: expression has no effect
You can, however, still have strings prefixed with "string:".

pawn Code:
main()
{
    inline Func(string:arr[])
    {
    }
}

9)
  • Code

pawn Code:
uvar
    gFirst[MAX_PLAYERS][10], // Error line.
    gSecond[MAX_PLAYERS][10];
  • Problem

Code:
<path>\errors.pwn(9) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
  • Solution

Variables declared with "new" or "stock" etc often follow the new line pattern above. For technical reasons this cannot be done with "uvar" and "svar" variables. Each one must be on the same line as a "uvar" or "svar" declaration.

pawn Code:
uvar gFirst[MAX_PLAYERS][10];
uvar gSecond[MAX_PLAYERS][10];

10)
  • Code

pawn Code:
public DoRead(name[], value[])
{
    INI_String("key", gValue); // Error line.
}
  • Problem

Code:
<path>\errors.pwn(12) : error 017: undefined symbol "INI_String"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
  • Solution

"INI_String" DOES exist, it just gives an unusual error when the last parameter is missed off. You must call it with the destination length.

pawn Code:
public DoRead(name[], value[])
{
    INI_String("key", gValue, sizeof (gValue));
}

11)
  • Code

pawn Code:
#include <YSI\y_commands>
  • Problem

Code:
<include>\YSI\y_debug.inc(367) : error 036: empty statement
<include>\YSI\y_debug.inc(367) : error 036: empty statement
<include>\YSI\y_amx.inc(367) : error 036: empty statement
<include>\YSI\y_amx.inc(367) : error 036: empty statement
<include>\YSI\y_amx.inc(411) : error 036: empty statement
<include>\YSI\y_amx.inc(411) : error 036: empty statement
<include>\YSI\y_amx.inc(646) : error 036: empty statement
<include>\YSI\y_amx.inc(646) : error 036: empty statement
<include>\YSI\y_amx.inc(780) : error 036: empty statement
<include>\YSI\y_amx.inc(780) : error 036: empty statement
<include>\YSI\y_amx.inc(938) : error 036: empty statement
<include>\YSI\y_amx.inc(938) : error 036: empty statement
<include>\YSI\y_amx.inc(958) : error 036: empty statement
<include>\YSI\y_amx.inc(958) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(144) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(144) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(150) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(150) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(159) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(159) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(174) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(174) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(183) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(183) : error 036: empty statement
<include>\YSI\internal\y_dohooks.inc(125) : error 036: empty statement
<include>\YSI\internal\y_dohooks.inc(125) : error 036: empty statement

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
  • Solution

When you get hundreds of errors like this inside YSI, it tends to be caused by using a non-standard editor (i.e. not PAWNO). There is nothing wrong with other editors, some are just set up with different default command line parameters for PAWNCC (the compiler). You need to make sure that you pass these two important switches:

Code:
-;+ -(+
12)
  • Code

pawn Code:
timer X[100]() // Error line.
{
}
  • Problem

Code:
<path>\errors.pwn(3) : warning 218: old style prototypes used with optional semicolon
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
  • Solution

This seems to be caused by using Raven's RolePlay, who for some inexplicable reason decided to ignore standard SA:MP formatting and remove semi-colons. To fix this you first need to remove this line:

pawn Code:
#pragma semicolon 0

Then fix all the other errors that come up because they are missing so many semi-colons. Blame them, not me - this is what happens when you ignore community-wide standards!

13)
  • Code

pawn Code:
hook OnGameModeInit() // Error line.
{
}
  • Problem

Code:
<path>\errors.pwn(3) : error 021: symbol already defined: "@yH_GameModeInit2"
<path>\errors.pwn(3) : error 021: symbol already defined: "@yH_GameModeInit2"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
  • Solution

This applies to any callback hooked and and number on the end, for example "@yH_PlayerDisconnect42". The problem is caused by including y_hooks before other includes, as they may also use y_hooks:

pawn Code:
#include <YSI\y_hooks>
#include <other>

hook OnGameModeInit() // Error line.
{
}

Should be:

pawn Code:
#include <other>
#include <YSI\y_hooks>

hook OnGameModeInit() // Error line.
{
}

14)
  • Code

pawn Code:
#include "internal\y_version" // Error line.
  • Problem

Code:
pawno\include\YSI/y_ini.inc(161) : fatal error 100: cannot read from file: "internal\y_version"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
  • Solution

The true problem is here:

Code:
\YSI/y_ini.inc
Somewhere in your code, or in one of the includes in your code, a file has been included incorrectly. ALL YSI files MUST be included using a backslash, NOT a forward slash. Change:

pawn Code:
#include <YSI/y_ini>

To:

pawn Code:
#include <YSI\y_ini>

Repeat for all other includes done wrong (i.e using "YSI/" not "YSI\").

Last edited by Y_Less; 28/05/2012 at 03:30 PM.
Y_Less is offline   Reply With Quote
Old 26/02/2012, 01:31 PM   #2
Mr.Fames
Huge Clucker
 
Join Date: Oct 2011
Posts: 350
Reputation: 24
Default Re: YSI Errors and Warnings

Very Useful thread man , thanks
__________________
Mr.Fames is offline   Reply With Quote
Old 26/02/2012, 01:53 PM   #3
MarcObeles20
Big Clucker
 
Join Date: Dec 2011
Location: Manila, Philippines
Posts: 168
Reputation: 34
Default Re: YSI Errors and Warnings

Wow! I can finally fix my errors! Thank you!!!
__________________
MarcObeles20 is offline   Reply With Quote
Old 26/02/2012, 05:57 PM   #4
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 17,542
Reputation: 2438
Default Re: YSI Errors and Warnings

Two common ones related to alternate editors added.
Y_Less is offline   Reply With Quote
Old 27/02/2012, 06:50 AM   #5
Gamer_Z
High-roller
 
Gamer_Z's Avatar
 
Join Date: Jun 2009
Location: Fontys Uni. - Applied Sciences (Currently doing the hardest possible study Fontys has to offer)
Posts: 2,617
Reputation: 819
Default Re: YSI Errors and Warnings

little typo in 10)

Quote:
public DoRead(name[], value[]){ INI_String("key", gValue, sizeof (gValue);}
should be:
Quote:
public DoRead(name[], value[]){ INI_String("key", gValue, sizeof (gValue));}
or
Quote:
public DoRead(name[], value[]){ INI_String("key", gValue, sizeof gValue);}//should work...
__________________

Google code not working? Try GitHub
Gamer_Z is offline   Reply With Quote
Old 27/02/2012, 06:57 AM   #6
[HK]Ryder[AN]
High-roller
 
[HK]Ryder[AN]'s Avatar
 
Join Date: Jan 2012
Location: New Delhi, India
Posts: 1,241
Reputation: 358
Default Re: YSI Errors and Warnings

Good tutorial!Good help ppl
__________________


[HK]Ryder[AN] is offline   Reply With Quote
Old 27/02/2012, 09:13 PM   #7
mehdi-jumper
High-roller
 
mehdi-jumper's Avatar
 
Join Date: Sep 2011
Location: New-Zealand
Posts: 1,894
Reputation: 51
Default Re: YSI Errors and Warnings

Thanks for this tutorial, very usefull

Bye!
mehdi-jumper is offline   Reply With Quote
Old 19/03/2012, 04:15 AM   #8
dudaefj
Huge Clucker
 
dudaefj's Avatar
 
Join Date: Jul 2011
Posts: 359
Reputation: 19
Default Respuesta: YSI Errors and Warnings

Quote:
Originally Posted by Y_Less View Post
Introduction

pawn Code:
#include <YSI\y_commands>
  • Problem

Code:
<include>\YSI\y_debug.inc(367) : error 036: empty statement
<include>\YSI\y_debug.inc(367) : error 036: empty statement
<include>\YSI\y_amx.inc(367) : error 036: empty statement
<include>\YSI\y_amx.inc(367) : error 036: empty statement
<include>\YSI\y_amx.inc(411) : error 036: empty statement
<include>\YSI\y_amx.inc(411) : error 036: empty statement
<include>\YSI\y_amx.inc(646) : error 036: empty statement
<include>\YSI\y_amx.inc(646) : error 036: empty statement
<include>\YSI\y_amx.inc(780) : error 036: empty statement
<include>\YSI\y_amx.inc(780) : error 036: empty statement
<include>\YSI\y_amx.inc(938) : error 036: empty statement
<include>\YSI\y_amx.inc(938) : error 036: empty statement
<include>\YSI\y_amx.inc(958) : error 036: empty statement
<include>\YSI\y_amx.inc(958) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(144) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(144) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(150) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(150) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(159) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(159) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(174) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(174) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(183) : error 036: empty statement
<include>\YSI\internal\y_shortfunc.inc(183) : error 036: empty statement
<include>\YSI\internal\y_dohooks.inc(125) : error 036: empty statement
<include>\YSI\internal\y_dohooks.inc(125) : error 036: empty statement

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
  • Solution

When you get hundreds of errors like this inside YSI, it tends to be caused by using a non-standard editor (i.e. not PAWNO). There is nothing wrong with other editors, some are just set up with different default command line parameters for PAWNCC (the compiler). You need to make sure that you pass these two important switches:

Code:
-;+ -(+

sorry for bump, but...
How do I do that?

I'm using PawnScITe from Darkimmortal
dudaefj is offline   Reply With Quote
Old 03/04/2012, 02:35 AM   #9
dudaefj
Huge Clucker
 
dudaefj's Avatar
 
Join Date: Jul 2011
Posts: 359
Reputation: 19
Default Respuesta: YSI Errors and Warnings

bump?
dudaefj is offline   Reply With Quote
Old 03/04/2012, 03:11 AM   #10
antonio112
High-roller
 
antonio112's Avatar
 
Join Date: Aug 2009
Location: Romania
Posts: 1,013
Reputation: 86
Default Re: YSI Errors and Warnings

Quote:
Originally Posted by Y_Less View Post
Introduction

YSI uses A LOT of macros to make things easier to write. The downside to this is that it can make errors and warnings very hard to interpret as they will refer to code after macro replacement is done. This guide should help you to translate the given errors to the real errors.

I will add more as I become aware of them.

Errors and Warnings
  • 1)
  • Code

pawn Code:
// Alternate:
//CMD:help(playerid, params[])
YCMD:help(playerid, params[], help) // Warning line.
{
    // Some code here.
}
  • Problem

Code:
<path>\errors.pwn(11) : warning 203: symbol is never used: "help"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
  • Solution

You didn't include "YSI\y_commands". Commands are never explicitly called anywhere in code, so the compiler needs to be told that they will be called eventually.

pawn Code:
#include <YSI\y_commands>
Am I missing something here or? If you get the "symbol is never used "help"" warning, don't you just have to:
pawn Code:
#pragma unused help

Or you did a mistake regarding the warning / error you get ?

Anyhow, great tutorial overall, really helpful.

ps: Maybe you pasted the wrong error ?
__________________
antonio112 is offline   Reply With Quote
Reply

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
Some errors and warnings MusicBeast Scripting Help 2 11/10/2011 02:02 PM
Some errors/warnings Anzhelov Server Support 1 21/02/2011 10:22 PM
Errors/Warnings help marinov Help Archive 4 06/11/2010 07:07 PM
5 Errors and 3 Warnings nuriel8833 Help Archive 2 28/08/2010 07:07 AM


All times are GMT. The time now is 03:42 AM.


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