Cannot compile on Platformio; error: narrowing conversion
lou42 opened this issue · comments
line of errors when compiling for a trinket M0 on Platformio.
lib\IRLibProtocols\IRLibSAMD21.cpp:108:1: error: narrowing conversion of '(_ETCChannel)-1' from 'short int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
*** [.pio\build\adafruit_trinket_m0\lib7bb\IRLibProtocols\IRLibSAMD21.cpp.o] Error 1
I cannot find this problem. I don't make use of "short int" in that file. And anyway "short int" should be an eight bit value anyway. The code compiles fine using the Arduino IDE. I'm not familiar with Platformio but it's something wrong with their definition of "short int".
Thanks for looking into this.
Platformio runs on Visual Studio Code and Atom and is a cross platform code builder and library manager for platforms like Arduino.
I searched through every file I am working with and 'short int' doesn't exist in any of my code either.
Regardless, I was able to get the code to compile by replacing all instances of 'uint8_t' in IRLibSAMD21.cpp with 'short int'.
Just ran into the same issue. My understanding of the Arduino ecosystem is still quite limited, but here I get the impression the ETCChannel enum value NOT_ON_TIMER may be -1, which is assigned to the uint8_t field of the _IR_PWM_Map struct in IRLibSAMD21.cpp. Changing the IR_PER_EorF field to be of type short int resolved the error.
Appears to be related to using a SAMD Arduino board, personally using the MKR1000.
@Saberos that is correct NOT_ON_TIMER is -1. For some reason the Arduino IDE doesn't flag that as an error. Could you try using "int8_t" instead of "uint8_t" or "short int" and tell me if it still works?
I had the same problem, after updating to Arduino IDE 2 rc3 and updating the Arduino Nano 33 IoT in the Board Manager to "Arduino SAMD Boards 1.8.12", my code did no longer compile. Downgrading to 1.8.11 didn't help.
Regardless, I was able to get the code to compile by replacing all instances of 'uint8_t' in IRLibSAMD21.cpp with 'short int'.
This also helped in my case.