why is my class not known in this scope?

I broke down my more complex code down to this:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

struct Actor{
  int x;
};

void act(Actor t){
}

and I get the following error:

sketch_dec05a:19:10: error: variable or field 'act' declared void
 void act(Actor t){
          ^~~~~
sketch_dec05a:19:10: error: 'Actor' was not declared in this scope
exit status 1
variable or field 'act' declared void

Why? It’s literally declared right above “act”. Running the same code in a c++ compiler doesn’t produce this error.

It due to the annoying (IMO) auto-prototype generator in the Arduino IDE. Simplest solution is to more the struct definition to the top above setup() and loop().

You could also do something that looks brain-dead but works because you're supplying the prototype:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

struct Actor{
  int x;
};

void act(Actor t);

void act(Actor t){
}

gfvalvo:
It due to the annoying (IMO) auto-prototype generator in the Arduino IDE. Simplest solution is to more the struct definition to the top above setup() and loop().

You could also do something that looks brain-dead but works because you're supplying the prototype:

void setup() {

// put your setup code here, to run once:
}

void loop() {
 // put your main code here, to run repeatedly:
}

struct Actor{
 int x;
};

void act(Actor t);

void act(Actor t){
}

Thank you, it works!