Change of global state enum to int value in a function
Posted: Wed Feb 21, 2018 6:10 am
Hello,
It's been several months since I have a compilation error on when I want to change the value of an enumeration declared at the beginning of the program (global), in a function that replaces it with an integer.
Before I did not have this problem, but having switched my code from a mini arduino card, to ESP8266 the problem appeared .. It do not have the same compiler ??
The error below is still blocking and prevents me from advancing on my project .. I can not find the solution:
Here is a simplified example of the problem:
What could be the solution? I do not understand..
It's been several months since I have a compilation error on when I want to change the value of an enumeration declared at the beginning of the program (global), in a function that replaces it with an integer.
Before I did not have this problem, but having switched my code from a mini arduino card, to ESP8266 the problem appeared .. It do not have the same compiler ??
The error below is still blocking and prevents me from advancing on my project .. I can not find the solution:
Code: Select all
ERROR : request for member 'state' in 'CYCLE_ARROSAGE', which is of non-class type '<anonymous enum>'
Here is a simplified example of the problem:
Code: Select all
enum {S, // SECURITE
N, // NUIT
J1_1, J1_2, J1_3, // Luminosité 1
J2_1, J2_2, J2_3, // Luminosité 2
J3_1, J3_2, J3_3, // Luminosité 3
} CYCLE_ARROSAGE; // SECURITE
void setup () {
CYCLE_ARROSAGE = N; // OK
}
void loop () {
CheckChangementCycleArrosage(J2_2);
}
void CheckChangementCycleArrosage(int NouveauCycle ){
if(CYCLE_ARROSAGE != NouveauCycle){
Serial.print("CYCLE CHECKE : ");
Serial.println(NouveauCycle); // -> 6
Serial.print("CYCLE CHECKE CAST: ");
Serial.println(String(NouveauCycle)); // -> 6
Serial.print("CYCLE ARROSAGE: ");
Serial.println(CYCLE_ARROSAGE); // -> 1
CYCLE_ARROSAGE = NouveauCycle; // -> ERROR
}
}
What could be the solution? I do not understand..