[SOLVED] Getting dynamic pointer array out of struct

Started by Snarky, Fri 18/04/2025 07:35:05

Previous topic - Next topic

Snarky

I'm getting a syntax error I can't figure out (AGS v3.6.1). As a minimal example:

Code: ags
struct Storage
{
  Object* oArray[];
}

Object*[] GetArray()
{
  Storage s;
  Object* oArray[] = s.oArray; // <-- Error "Type mismatch: cannot convert 'Object*' to 'Object*[]'"
  return oArray;
}

It works if I do:

Code: ags
Object*[] GetArray()
{
  Object* dummyArray[];
  Object* oArray[] = dummyArray;
  return oArray;
}

... So it must have something to do with accessing it from the struct. Is there a correct syntax, or have I hit an engine limitation?

Crimson Wizard

I posted your first code snippet into 3.6.1 editor, and it compiled fine...

Snarky

Damn, I must have made a mistake when I reduced it to the simplest case. The error had to do with an array of this struct, which isn't permitted, but it never got to that exception. Thanks!

SMF spam blocked by CleanTalk