Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By lcharpen17
#74100 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:

Code: Select allERROR : 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 allenum {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..
User avatar
By mrburnette
#74143 I ran the same code for Generic ESP8266 Module, 80MHz, DIO, 115200, 512K (64K SPIFF)

The code compiled without error:
Code: Select allArchiving built core (caching) in: /tmp/arduino_cache_430938/core/core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____e309d7f2e5c52c64897dde81c89148e3.a
Linking everything together...
"/home/ray/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-gcc" -g -w -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L/home/ray/.arduino15/packages/esp8266/hardware/esp8266/2.3.0-rc2/tools/sdk/lib" "-L/home/ray/.arduino15/packages/esp8266/hardware/esp8266/2.3.0-rc2/tools/sdk/ld" "-Teagle.flash.512k64.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy  -o "/tmp/arduino_build_243985/junk.ino.elf" -Wl,--start-group "/tmp/arduino_build_243985/sketch/junk.ino.cpp.o" "/tmp/arduino_build_243985/arduino.ar" -lm -lgcc -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 -llwip_gcc -lstdc++ -Wl,--end-group  "-L/tmp/arduino_build_243985"
"/home/ray/.arduino15/packages/esp8266/tools/esptool/0.4.8/esptool" -eo "/home/ray/.arduino15/packages/esp8266/hardware/esp8266/2.3.0-rc2/bootloaders/eboot/eboot.elf" -bo "/tmp/arduino_build_243985/junk.ino.bin" -bm dio -bf 40 -bz 512K -bs .text -bp 4096 -ec -eo "/tmp/arduino_build_243985/junk.ino.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
Sketch uses 221947 bytes (51%) of program storage space. Maximum is 434160 bytes.
Global variables use 31520 bytes (38%) of dynamic memory, leaving 50400 bytes for local variables. Maximum is 81920 bytes.


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() {
}