SA-MP Forums Archive
warning 224: indeterminate array size in "sizeof" expression (symbol "") - 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)
+--- Thread: warning 224: indeterminate array size in "sizeof" expression (symbol "") (/showthread.php?tid=468536)



warning 224: indeterminate array size in "sizeof" expression (symbol "") - Fierro - 08.10.2013

pawn Code:
public ChangePlayerDecisions(playerid,decisions[])
{
    new fm[128];
    for(new i = 0; i < sizeof(decisions); i++)//line 523
    {
        PlayerDecisions[playerid][i] = decisions[i];
        format(fm,sizeof(fm),"/%i: %s",i+1,decisionMessages[i]);
        OnPlayerDecisionsChange(playerid,decisions);
    }
    return 1;
}
Error:
Code:
(523) warning 224: indeterminate array size in "sizeof" expression (symbol "")
Can someone please explain? I'm using sizeof with an existing symbol, so why is it blank there? Is it undetermined somehow because I didn't specify a length in the function's declaration/definition?


Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - Jefff - 08.10.2013

Try
pawn Code:
public ChangePlayerDecisions(playerid,decisions[], s_size = sizeof(decisions))
for(new i = 0; i < s_size-1; i++)//line 523



Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - Fierro - 08.10.2013

EDIT: Never mind. Didn't have to be public (don't know why it was in the first place). Thanks, repping


Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - Fierro - 08.10.2013

Having another problem:
pawn Code:
ChangePlayerDecisions(playerid,{DECISION_SETTINGS_CHANGE_PASS,DECISION_SETTINGS_SHOW_DEATHS,DECISION_SETTINGS_PREF_CITY,DECISION_SETTINGS_MAX_TRIES});//line 736 (duh)
Errors:
Code:
....pwn(736) : error 001: expected token: "}", but found ";"
....pwn(736) : error 001: expected token: ",", but found ";"
....pwn(736) : error 029: invalid expression, assumed zero
....pwn(736) : fatal error 107: too many error messages on one line
Edit: And yes, the DECISION_... variables are defined:
pawn Code:
#define DECISION_SETTINGS_CHANGE_PASS 0;
#define DECISION_SETTINGS_SHOW_DEATHS 1;
#define DECISION_SETTINGS_PREF_CITY 2;
#define DECISION_SETTINGS_MAX_TRIES 3;



Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - SuperViper - 08.10.2013

Why are your parameters wrapped in { }?


Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - Jefff - 08.10.2013

pawn Code:
#define DECISION_SETTINGS_CHANGE_PASS   0
#define DECISION_SETTINGS_SHOW_DEATHS   1
#define DECISION_SETTINGS_PREF_CITY     2
#define DECISION_SETTINGS_MAX_TRIES     3

@ChangePlayerDecisions(playerid, ...); // its forward
@ChangePlayerDecisions(playerid, ...) // its public
{
    //new fm[128];
    new
        i = 1, // 1 because we have 'playerid' as first
        n = numargs()
    ;

    while(i < n)
    {
        PlayerDecisions[playerid][i-1] = getarg(i);
        //format(fm,sizeof(fm),"/%i: %s",i+1,decisionMessages[i]);
        OnPlayerDecisionsChange(playerid,decisions);
        i++;
    }
    return 1;
}

// Usage
@ChangePlayerDecisions(playerid,DECISION_SETTINGS_CHANGE_PASS,DECISION_SETTINGS_SHOW_DEATHS,DECISION_SETTINGS_PREF_CITY,DECISION_SETTINGS_MAX_TRIES);
and show OnPlayerDecisionsChange


Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - Fierro - 09.10.2013

Quote:
Originally Posted by Jefff
View Post
pawn Code:
#define DECISION_SETTINGS_CHANGE_PASS   0
#define DECISION_SETTINGS_SHOW_DEATHS   1
#define DECISION_SETTINGS_PREF_CITY     2
#define DECISION_SETTINGS_MAX_TRIES     3

@ChangePlayerDecisions(playerid, ...); // its forward
@ChangePlayerDecisions(playerid, ...) // its public
{
    //new fm[128];
    new
        i = 1, // 1 because we have 'playerid' as first
        n = numargs()
    ;

    while(i < n)
    {
        PlayerDecisions[playerid][i-1] = getarg(i);
        //format(fm,sizeof(fm),"/%i: %s",i+1,decisionMessages[i]);
        OnPlayerDecisionsChange(playerid,decisions);
        i++;
    }
    return 1;
}

// Usage
@ChangePlayerDecisions(playerid,DECISION_SETTINGS_CHANGE_PASS,DECISION_SETTINGS_SHOW_DEATHS,DECISION_SETTINGS_PREF_CITY,DECISION_SETTINGS_MAX_TRIES);
and show OnPlayerDecisionsChange
Still some errors:
Code:
heist92_01b.pwn(736) : error 001: expected token: ",", but found ";"
heist92_01b.pwn(736) : error 029: invalid expression, assumed zero
heist92_01b.pwn(736) : warning 215: expression has no effect
heist92_01b.pwn(736) : error 029: invalid expression, assumed zero
heist92_01b.pwn(736) : fatal error 107: too many error messages on one line



Re: warning 224: indeterminate array size in "sizeof" expression (symbol "") - Fierro - 12.10.2013

Bump.