SA-MP Forums Archive
[Tutorial] YSI errors and warnings - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] YSI errors and warnings (/showthread.php?tid=570894)



YSI errors and warnings - Misiur - 14.04.2015

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)
pawn Код:
// Alternate:
//CMD:kickplayer(playerid, params[])
YCMD:kickplayer(playerid, params[], help) // Warning line.
{
    // Some code here.
}
Код:
<path>\errors.pwn(11) : warning 203: symbol is never used: "kickplayer"
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Warning.
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 Код:
#include <YSI\y_commands>
2)
pawn Код:
timer X() // Error line.
{
}
Код:
<path>\errors.pwn(3) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


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

pawn Код:
timer X[100]()
{
}
3)
pawn Код:
X[100]() // Error line.
{
}
Код:
<path>\errors.pwn(3) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


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

pawn Код:
timer X[100]()
{
}
4)
pawn Код:
timer X[100](arr[]) // Error line.
{
}
Код:
<path>\errors.pwn(3) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Error.
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 Код:
timer X[100](arr[], size)
{
}
pawn Код:
timer X[100](string:arr[])
{
}
5)
pawn Код:
main()
{
    new
        Iterator:x<100>; // Warning line.
    foreach (new i : x)
    {
    }
}
Код:
<path>\errors.pwn(6) : warning 203: symbol is never used: "x@YSII_Cg"
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Warning.
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 Код:
main()
{
    new
        Iterator:x<100>;
    Iter_Add(x, 10);
    foreach (new i : x)
    {
    }
}
6)
pawn Код:
main()
{
    new
        Iterator:x<100>;
    Iter_Add(x, 10);
    foreach (i : x) // Error line.
    {
    }
}
Код:
<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 © 1997-2006, ITB CompuPhase


4 Errors.
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 Код:
main()
{
    new
        Iterator:x<100>;
    Iter_Add(x, 10);
    foreach (new i : x)
    {
    }
}
7) The compiler hangs. 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 Код:
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 Код:
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)
pawn Код:
main()
{
    inline Func(arr[]) // Error line.
    {
    }
}
Код:
<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 © 1997-2006, ITB CompuPhase


4 Errors.
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:

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

pawn Код:
main()
{
    inline Func(string:arr[])
    {
    }
}
9)
pawn Код:
uvar
    gFirst[MAX_PLAYERS][10], // Error line.
    gSecond[MAX_PLAYERS][10];
Код:
<path>\errors.pwn(9) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Error.
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 Код:
uvar gFirst[MAX_PLAYERS][10];
uvar gSecond[MAX_PLAYERS][10];
10)
pawn Код:
public DoRead(name[], value[])
{
    INI_String("key", gValue); // Error line.
}
Код:
<path>\errors.pwn(12) : error 017: undefined symbol "INI_String"
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Error.
"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 Код:
public DoRead(name[], value[])
{
    INI_String("key", gValue, sizeof (gValue));
}
11)
pawn Код:
#include <YSI\y_commands>
Код:
<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 © 1997-2006, ITB CompuPhase


26 Errors.
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:

Код:
-;+ -(+
12)
pawn Код:
timer X[100]() // Error line.
{
}
Код:
<path>\errors.pwn(3) : warning 218: old style prototypes used with optional semicolon
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Warning.
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]#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)
pawn Код:
hook OnGameModeInit() // Error line.
{
}
Код:
<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 © 1997-2006, ITB CompuPhase


1 Warning.
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 Код:
#include <YSI\y_hooks>
#include <other>

hook OnGameModeInit() // Error line.
{
}
Should be:

pawn Код:
#include <other>
#include <YSI\y_hooks>

hook OnGameModeInit() // Error line.
{
}
14)
pawn Код:
#include "internal\y_version" // Error line.
Код:
pawno\include\YSI/y_ini.inc(161) : fatal error 100: cannot read from file: "internal\y_version"
Pawn compiler 3.2.3664          Copyright © 1997-2006, ITB CompuPhase


1 Error.
The true problem is here:

Код:
\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 Код:
#include <YSI/y_ini>
To:

pawn Код:
#include <YSI\y_ini>
Repeat for all other includes done wrong (i.e using "YSI/" not "YSI\").


Re: YSI errors and warnings - Pomminger - 19.07.2015

Thanks Dude !


Respuesta: YSI errors and warnings - thegameover81 - 23.03.2016

Ayuda porfa me dice error 021 symbol already defined "NameTimer" Ayuda porfavor