kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.6k stars 347 forks source link

No longer compiling with VS code / PIO #360

Open snowrodeo opened 1 month ago

snowrodeo commented 1 month ago

I did an update and now the latest lib no longer compiles. Here are the errors I am seeing

/Users/erikolson/.platformio/packages/toolchain-xtensa-esp32s3/xtensa-esp32s3-elf/include/c++/8.4.0/bits/stl_vector.h: In member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::_M_check_len(std::vector<_Tp, _Alloc>::size_type, const char*) const':
.pio/libdeps/ESPChecker_v4/WS2812FX/src/WS2812FX.h:52:3: error: expected unqualified-id before '(' token
   ({ __typeof__ (a) _a = (a); \
   ^
.pio/libdeps/ESPChecker_v4/WS2812FX/src/WS2812FX.h:52:6: error: expected primary-expression before '__typeof__'
   ({ __typeof__ (a) _a = (a); \
      ^~~~~~~~~~
.pio/libdeps/ESPChecker_v4/WS2812FX/src/WS2812FX.h:52:6: error: expected '}' before '__typeof__'
.pio/libdeps/ESPChecker_v4/WS2812FX/src/WS2812FX.h:52:6: error: expected ')' before '__typeof__'
.pio/libdeps/ESPChecker_v4/WS2812FX/src/WS2812FX.h:54:5: error: '_a' was not declared in this scope
     _a > _b ? _a : _b; })
     ^~
.pio/libdeps/ESPChecker_v4/WS2812FX/src/WS2812FX.h:54:5: note: suggested alternative: '_b'
snowrodeo commented 1 month ago

I just created a PR for a fix to this issue. Not sure how elegant my fix is, but it does the trick for me.

moose4lord commented 1 month ago

Ugh, those min/max macros have always been problematic. Rather than fix the issue with a different macro, I'd prefer to switch the code to use std::min and std::max. That's been on my to-do list for a while.

I don't really use PlatformIO, but I installed its extension in VS Code, ran the ws2812fx_segments example sketch, and it seemed to work ok. But that could just be me not knowing what I'm doing.

Can you try to reproduce this issue with the Arduino IDE? That'll make it easier for me to debug.

snowrodeo commented 1 month ago

The compilers/versions must be different between Arduino IDE and Platformio. I will dig in on that a bit and see if I can get the error to happen in IDE OR make a simple case in Platformio. In the meantime, I will change my solve to use std::max and check it. That would be a better solution compared to my hack.

snowrodeo commented 1 month ago

New PR with std::max usage implemented

moose4lord commented 4 weeks ago

OK, the switch to std::min/std::max doesn't work for AVR boards, since AVR boards don't seem to support the C++ STL. So I'll have to rethink that.

I'm back to trying to recreate the issue with PlatformIO, which I normally don't use. I installed PlatformIO and created a project with a simple WS2812FX sketch. It builds, uploads and runs on my ESP32 with no issues. I'm not sure what I'm doing "right".

PlatformIO prints this info when I compile the sketch:

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/mhetesp32minikit.html
PLATFORM: Espressif 32 (3.5.0) > MH ET LIVE ESP32MiniKit
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.10006.210326 (1.0.6) 
 - tool-esptoolpy @ 1.30100.210531 (3.1.0) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-xtensa32 @ 2.50200.97 (5.2.0)

The Arduino_ESP core v1.0.6 and ESP IDF v3.5.0 are quite old. Should I try upgrading to new versions? How would I do that?

Any help with reproducing the issue on my end would be appreciated.

snowrodeo commented 3 weeks ago

I will work on the platformio stuff next Monday when work schedule frees up.

Do you want to try the first PR on the AVR platform? This is a new macro that works on the ESP32. It might work on the AVR as well. Since we can’t use STD on AVR, this might be the path

From: Keith Lord @.> Date: Thursday, October 24, 2024 at 6:01 AM To: kitesurfer1404/WS2812FX @.> Cc: Erik Olson @.>, Author @.> Subject: Re: [kitesurfer1404/WS2812FX] No longer compiling with VS code / PIO (Issue #360)

OK, the switch to std::min/std::max doesn't work for AVR boards, since AVR boards don't seem to support the C++ STL. So I'll have to rethink that.

I'm back to trying to recreate the issue with PlatformIO, which I normally don't use. I installed PlatformIO and created a project with a simple WS2812FX sketch. It builds, uploads and runs on my ESP32 with no issues. I'm not sure what I'm doing "right".

PlatformIO prints this info when I compile the sketch:

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/mhetesp32minikit.html

PLATFORM: Espressif 32 (3.5.0) > MH ET LIVE ESP32MiniKit

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)

PACKAGES:

The Arduino_ESP core v1.0.6 and ESP IDF v3.5.0 are quite old. Should I try upgrading to new versions? How would I do that?

Any help with reproducing the issue on my end would be appreciated.

— Reply to this email directly, view it on GitHubhttps://github.com/kitesurfer1404/WS2812FX/issues/360#issuecomment-2435234225, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAN3UDQYV7GB637RFMVYJQ3Z5DVRRAVCNFSM6AAAAABQGM4AA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZVGIZTIMRSGU. You are receiving this because you authored the thread.Message ID: @.***>