struct typedef compilation error

When I try to compile this test case with 1.5.2 for a Due:

typedef struct {
  int aMember;
} MyStruct;

MyStruct* pInstance;

void dumpStruct(MyStruct* m)
{
}

void setup()
{
  dumpStruct(pInstance);
}

void loop()
{
}

… I get:

ArduinoSPBM:3 error: variable or field 'dumpStruct' declared void 
ArduinoSPBM:3 error: 'MyStruct' was not declared in this scope
ArduinoSPBM:3 error: 'm' was not declared in this scope

Line 3 is the structure member ‘aMember’.

It compiles OK with g++ with main() calling setup().

What am I doing wrong?

Thanks…

Its an issue with how Arduino IDE handles the function prototypes (puts them at the top).

typedef struct {
  int aMember;
} MyStruct;

MyStruct* pInstance;

void dumpStruct(MyStruct* m);

void dumpStruct(MyStruct* m)
{
}

void setup()
{
  dumpStruct(pInstance);
}

void loop()
{
}

Manually added the function prototype and it compiles.

Thanks, that was it. Why doesn't it apply to functions with only primitive arguments?

gutbag: Thanks, that was it. Why doesn't it apply to functions with only primitive arguments?

No idea, that's just how the Arduino guys coded it.

gutbag: Why doesn't it apply to functions with only primitive arguments?

Because the IDE 'feature' that generates automatic function prototypes was not designed properly.