sourcepawn icon indicating copy to clipboard operation
sourcepawn copied to clipboard

using enum struct as parameter when it's declaring

Open Starbish opened this issue 6 years ago • 4 comments

https://pastebin.com/U1fSY62u

Compiler says "error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')"

But i doubt it's an invalid expression. Is this a bug? or It's just an invalid expression?

What i tried to make was to check the data between two different PlayerTable to confirm it's identical or not.

like this,

https://pastebin.com/Bdw5axYu

Starbish avatar Jan 07 '19 11:01 Starbish

Please use inline code blocks rather than linking to an external site.

I suspect this is the same issue as #303, the type doesn't exist until it has finished parsing.

asherkin avatar Jan 07 '19 11:01 asherkin

enum struct PlayerTable2
{
    int a[4];
    void Test(PlayerTable2[1] test)
    {
        PrintToServer("%i", test[0].a[3]);
    }
}

public void OnPluginStart()
{
    PlayerTable2 x[1];
    x[0].a[3] = 123;
    x[0].Test(x);
}

One of SM discord user found that this expression worked as expected. Will I be able to use this expression even though it's not recommended?

Starbish avatar Jan 07 '19 14:01 Starbish

Yes unfortunately that is the issue. I would like to fix this but I haven't nailed down how yet.

In the meantime, it is better to have a global method, like "ComparePlayers(Player a, Player b)".

dvander avatar Feb 18 '19 21:02 dvander