bengtmartensson/Infrared4Arduino

Conflict with FastLED?

CobaltEcho opened this issue · 1 comments

From what I'm able to find via google: "You're trying to declare a variable with the same name as a macro,"

Board is a ATMega4809 (Nano Every)

C:\Users\Echo\Documents\Arduino\libraries\FastLED\src/fastpin.h:17:16: error: expected unqualified-id before numeric constant
 #define NO_PIN 255
                ^
C:\Users\Echo\Documents\Arduino\libraries\Infrared4Arduino\src/Board.h:64:28: note: in expansion of macro 'NO_PIN'
     static constexpr pin_t NO_PIN = 255U;
                            ^~~~~~
exit status 1
Error compiling for board Arduino Nano Every.

Is there a workaround for this? Appreciate any info!

Thank you for the report. I can reproduce: Just #include<FastLED.h> before an Infrared4Arduino include. Happens for all boards, not just Every.

What happens is that FastLED defines a global macro NO_PIN, which basically makes it impossible for any program to use that name for anything else. From the isolated line above, it appears as if Infrared4Arduino (Boards.h) also defines a global name, but that is not so: the line is in the class Board, and defines the name as a member, Board::NO_PIN. But, if NO_PIN is already a defined macro, it bombs of course.

It appears that if you include the FastLED include(-s?) after the Infrared4Arduino it will work. Also,

#undef NO_PIN

immediately after the include appears to work, but it may have effects on FastLED.

Feel free to complain to the FastLED maintainers about contaminating the global name space.