Hello, I was using this code in arduino-0023, and it works correctly. Now I want to use it with the arduino-ide_2.0.3_Windows_64bit ide, and I get some errors. {any solution?
union RGB {
struct {
uint8_t b;
uint8_t g;
uint8_t r;
//uint8_t a;
} color;
uint32_t bits;
RGB() { bits = 0; }
RGB(uint32_t color) { bits = color; }
RGB(uint8_t cr, uint8_t cg, uint8_t cb) { color.r = cr; color.g = cg; color.b = cb; }
operator uint32_t() { return bits; }
};
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:31:10: error: 'RGB::RGB()' cannot be overloaded
RGB() { bits = 0; }
^~~
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:31:2: error: with 'RGB::RGB()'
RGB() { bits = 0; }
^
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:32:10: error: 'RGB::RGB(uint32_t)' cannot be overloaded
RGB(uint32_t color) { bits = color; }
^~~
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:32:2: error: with 'RGB::RGB(uint32_t)'
RGB(uint32_t color) { bits = color; }
^
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:33:10: error: 'RGB::RGB(uint8_t, uint8_t, uint8_t)' cannot be overloaded
RGB(uint8_t cr, uint8_t cg, uint8_t cb) { color.r = cr; color.g = cg; color.b = cb; }
^~~
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:33:2: error: with 'RGB::RGB(uint8_t, uint8_t, uint8_t)'
RGB(uint8_t cr, uint8_t cg, uint8_t cb) { color.r = cr; color.g = cg; color.b = cb; }
^
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:35:10: error: 'RGB::operator uint32_t()' cannot be overloaded
operator uint32_t() { return bits; }
^~~~~~~~
C:\Users\titi\AppData\Local\Temp\.arduinoIDE-unsaved202313-18020-xopu4w.9y7u\sketch_feb3a\sketch_feb3a.ino:35:2: error: with 'RGB::operator uint32_t()'
operator uint32_t() { return bits; }
^
exit status 1
Compilation error: 'RGB::RGB()' cannot be overloaded