[AGS4 compiler] Syntax for static attributes?

Started by Monsieur OUXX, Yesterday at 23:59:00

Previous topic - Next topic

Monsieur OUXX

Code snippet :

Code: ags

///////////// IN THE HEADER FILE ////////////////

struct MyStruct
{
  import static attribute int SomeStaticValue;
};


//////////// In THE BODY ////////////////////////

int get_SomeStaticValue(this MyStruct*)
{
  ...
}

void set_SomeStaticValue(this MyStruct*, int value)
{
  ...
}


The compiler complains that
Code: ags
'MyStruct::get_SomeStaticValue' has the qualifiers '' here but 'static' elsewhere. See ./MyStruct.ash

If I change it like this :
Code: ags
static get_SomeStaticValue(this MyStruct*)
It still doesn't work.
Error:
Code: ags
Expected 'static', found 'this' instead
 

Crimson Wizard

#1
It should be "static Type", without a "pointer", and it's supported since AGS 3.4.0; the new compiler only forbids the incorrect syntax with a "this" pointer in this case.

Code: ags
int get_SomeStaticValue(static MyStruct)
{
}

EDIT: I think you can also do this instead:

Code: ags

static int MyStruct::get_SomeStaticValue()
{
}

SMF spam blocked by CleanTalk