Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Monsieur OUXX on Thu 17/07/2025 23:59:00

Title: [AGS4 compiler] Syntax for static attributes?
Post by: Monsieur OUXX on Thu 17/07/2025 23:59:00
Code snippet :


///////////// 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
'MyStruct::get_SomeStaticValue' has the qualifiers '' here but 'static' elsewhere. See ./MyStruct.ash

If I change it like this :
static get_SomeStaticValue(this MyStruct*)
It still doesn't work.
Error:
Expected 'static', found 'this' instead
Title: Re: [AGS4 compiler] Syntax for static attributes?
Post by: Crimson Wizard on Fri 18/07/2025 00:06:50
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) Select
int get_SomeStaticValue(static MyStruct)
{
}

EDIT: I think you can also do this instead (works with the new compiler):

Code (ags) Select

static int MyStruct::get_SomeStaticValue()
{
}