Your declaration is fine. However you need to understand that Arduino IDE automatically generates function prototypes for you. Unfortunately the IDE does a poor job. It sorts the generated prototypes to the top BEFORE the declarations. Thus you can not use them in any function definitions. Unless you prevent the IDE from auto generating the prototypes.
I found three ways to achieve this:
- Put your functions into a namespace and you get full control even in INO files.
- Move your functions into include files
- Wrap your functions into a macro such that the IDE does not recognize it as a function anymore. E.g. like the TRICK17 macro
For small files my preferred solution is #1. Your sketch would then be
namespace whatever {
typedef struct
{
int id;
int pin[5];
int tiempoCero;
int tiempoApagado;
int estado;
int vecinos[6];
} zonas;
function example(zonas z) {
...
}
}
void setup() {
...
}
void loop() {
whatever::zonas z;
...
whatever::example(z);
}
For an extensive example look here.