Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Snarky on Fri 18/04/2025 07:35:05

Title: [SOLVED] Getting dynamic pointer array out of struct
Post by: Snarky on Fri 18/04/2025 07:35:05
I'm getting a syntax error I can't figure out (AGS v3.6.1). As a minimal example:

Code (ags) Select
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) Select
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?
Title: Re: Getting dynamic pointer array out of struct
Post by: Crimson Wizard on Fri 18/04/2025 10:01:24
I posted your first code snippet into 3.6.1 editor, and it compiled fine...
Title: Re: Getting dynamic pointer array out of struct
Post by: Snarky on Fri 18/04/2025 11:16:35
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!