Why I get those warning? :S -
KosmasRego - 21.11.2011
When I putted #include <YSI> it shows those errors:
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(160) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(263) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(289) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_debug.inc(231) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_debug.inc(291) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_debug.inc(296) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_ini.inc(804) : warning 219: local variable "str" shadows a variable at a preceding level
pawn Код:
new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[126],ID;
Re: Why I get those warning? :S -
THE_KNOWN - 21.11.2011
remove new str[126]; before line 160
Re: Why I get those warning? :S -
Richie - 21.11.2011
goto the lines where the warning shows and remove 'new str[....'. If its in multiply places you get that warning.
Hope i explained so you could understand
Re: Why I get those warning? :S -
KosmasRego - 21.11.2011
line 160 is
pawn Код:
#define COLOR_MOCCASIN 0xFFE4B5FF
Re: Why I get those warning? :S -
sleepysnowflake - 21.11.2011
In what string do you use that color define ?
Re: Why I get those warning? :S -
KosmasRego - 21.11.2011
I don't use anywhere.
Re: Why I get those warning? :S -
AndreT - 21.11.2011
Quote:
Originally Posted by KosmasRego
line 160 is
pawn Код:
#define COLOR_MOCCASIN 0xFFE4B5FF

|
You can see the file the warning comes from is YSI/y_utils.inc in your includes folder, not the gamemode itself.
Do you do
anywhere above including YSI?
Re: Why I get those warning? :S -
KosmasRego - 21.11.2011
Pastebin
Re: Why I get those warning? :S -
Infinity - 21.11.2011
Quote:
Originally Posted by KosmasRego
When I putted #include <YSI> it shows those errors:
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(160) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(263) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(289) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_debug.inc(231) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_debug.inc(291) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_debug.inc(296) : warning 219: local variable "str" shadows a variable at a preceding level
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_ini.inc(804) : warning 219: local variable "str" shadows a variable at a preceding level
pawn Код:
new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[126],ID;
|
Ok, I'm going to teach you (all) how to read warnings.
This is a warning:
Quote:
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(160) : warning 219: local variable "str" shadows a variable at a preceding level
|
The first part with the directory can be ignored, as it is of no value in fixing the warning. What is interesting, however, is this: (The bold part)
Quote:
C:\Users\KosmasRego\Desktop\UCRP 1.1.250\pawno\include\YSI\y_utils.inc(160) : warning 219: local variable "str" shadows a variable at a preceding level
|
This indicates that the warning itself is not in
your script, but in an include you downloaded.
Now let's read the actual warning.
Quote:
warning 219: local variable "str" shadows a variable at a preceding level
|
The warning indicates that a local variable shadows another variable further in the script.
Local means that the vairable is defined
within a function.
This is a local variable:
pawn Код:
OnPlayerConnect(playerid)
{
new something;
The opposite of a local variable is a global variable, a variable that is defined outside of a function, which can be called from anywhere in the script.
Example:
pawn Код:
new something;
OnPlayerConnect(playerid)
{
But, let's continue. If a variable is shadowing another variable, it means that it is defining a variable which is already defined. A simple example of this would be:
pawn Код:
OnPlayerConnect(playerid){
new something;
//some random lines
new something;
return 1;
}
The variable is defined twice, which causes the warning.
In your case, I think you've defined "str" somewhere in your own script. You can fix the warning by opening your script, look for something along the lines of "new str;" or "new str[some number here];", and change "str" into something else.
(Don't forget to change "str" everwhere else in your script as well.)
Re: Why I get those warning? :S -
AndreT - 21.11.2011
Quote:
Originally Posted by Infinity
The warning indicates that a local variable shadows another variable further in the script.
Local means that the vairable is defined within a function.
[...]
But, let's continue. If a variable is shadowing another variable, it means that it is defining a variable which is already defined. A simple example of this would be:
pawn Код:
OnPlayerConnect(playerid){ new something; //some random lines new something; return 1; }
The variable is defined twice, which causes the warning.
In your case, I think you've defined "str" somewhere in your own script. You can fix the warning by opening your script, look for something along the lines of "new str;" or "new str[some number here];", and change "str" into something else.
|
Not necessarily.
I'm positive this code would generate the same warning:
pawn Код:
new str[128];
main()
{
}
public OnPlayerConnect(playerid)
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new str[128]; // <- warning
format(str, sizeof(str), "Hey, %s!", PlayerName);
SendClientMessage(playerid, 0xFFFFFFFF, str);
return true;
}
And renaming is perhaps not the best solution. I'm not familiar with the YSI framework but I can make assumptions str is used there. Switching to use global strings only would be a good call.