Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.8.3 does not compile anymore with gcc 4.8.2 (used by Tasmota for ESP8266) #1880

Closed
s-hadinger opened this issue Sep 16, 2022 · 7 comments · Fixed by #1881
Closed

v2.8.3 does not compile anymore with gcc 4.8.2 (used by Tasmota for ESP8266) #1880

s-hadinger opened this issue Sep 16, 2022 · 7 comments · Fixed by #1881
Labels

Comments

@s-hadinger
Copy link
Contributor

Version/revision of the library used

v2.8.3

Describe the bug

Tasmota uses gcc 4.8.2 for ESP8266 which does not support __VA_OPT__ extension.

Is there a way to rewrite the COND(<define_to_test>[||/&&<more_define>...], <true_result>, <false_result>) macro without __VA_OPT__?

Below is the first compilation error resported (there are many afterwards):

In file included from lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRtext.cpp:14:0:
lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h:22:40: error: pasting ")" and "THING" does not give a valid preprocessing token
 #define VA_TEST_P(a, ...) __VA_OPT__(NO)##THING
                                        ^
lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h:23:22: note: in expansion of macro 'VA_TEST_P'
 #define VA_TEST(...) VA_TEST_P(__VA_ARGS__)
                      ^
lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h:24:19: note: in expansion of macro 'VA_TEST'
 #define NEGATE(a) VA_TEST(a, a)
                   ^
lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h:25:51: note: in expansion of macro 'NEGATE'
 #define COND_P(cond, a, b) STUFF(a, cond)STUFF(b, NEGATE(cond))
                                                   ^
lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRmacros.h:26:33: note: in expansion of macro 'COND_P'
 #define COND(cond, a, b) EXPAND(COND_P(cond, a, b))
                                 ^
lib/lib_basic/IRremoteESP8266/IRremoteESP8266/src/IRtext.cpp:292:5: note: in expansion of macro 'COND'
     COND(DECODE_RC5 || SEND_RC5,

To Reproduce

Compilation error with gcc 4.8.2

Example code used

Expected behaviour

Output of raw data from [IRrecvDumpV2.ino]

What brand/model IR demodulator are you using?

Circuit diagram and hardware used (if applicable)

I have followed the steps in the [Troubleshooting Guide]

Has this library/code previously worked as expected for you?

Yes, 2.8.2 compiled fine

Other useful information

@Jason2866
Copy link

@tonhuisman Please have a look, i think EspEasy will fail to compile too.

@tonhuisman
Copy link
Contributor

Best solution would be to upgrade the gcc version, but I assume that's not an option, probably related to the Arduino framework version in use. (same problem at ESPEasy).

Simplest alternative is to add a test if __VA_OPT__ is supported, and define the COND() macro (set) based on that, but that won't give the real solution, as I would have used it like that already.

I can add a different macro PP_NARG() (also from the interwebz) to check if __VA_OPT__ can be used:

#if PP_NARG(__VA_OPT__(,)) != 2
#define COND(cond, a, b) a
#else
...// existing COND definition
#endif

This 'avoids' removing the not available protocols from the protocol-list, and also the check if a protocol is not available, but I assume that is currently only used in ESPEasy, as I designed it for use there.

@s-hadinger
Copy link
Contributor Author

This would be a good solution. If I understand well, ESP8266 will have the same behavior as before, while ESP32 (with gcc8) will have better features.

I'm not aware of the protocol-list. What is it?

@tonhuisman
Copy link
Contributor

I'm not aware of the protocol-list. What is it?

There is a function to fetch all supported protocols. After using the change I made, it will return ? if a protocol is not available, so you can check if the length is > 1 and only show the enabled protocols (used in ESPEasy to reduce build size by excluding unneeded protocols in a Custom build)

@tonhuisman
Copy link
Contributor

I think I've fixed it (see linked PR), with the side-note/limitation that the list of protocols contains all names, even when not included, but only for older compilers that don't support the __VA_OPT__ macro.

NB: This feature was introduced to reduce code-size as much as possible.

@s-hadinger
Copy link
Contributor Author

Thanks a lot. I confirm it's compiling fine on both esp8266 and esp32

crankyoldgit pushed a commit that referenced this issue Sep 18, 2022
Add check to see if `__VA_OPT__` macro is supported, if not, applies `<true_result>` value for `COND()` macro by default.

This has the side-effect/limitation that all protocol names are included in the build, even if the protocol is not available in the code, but _only_ for compilers dat do _not_ support the `__VA_OPT__` macro, notably gcc 4.8.2 (and older).

Resolves #1880
crankyoldgit added a commit that referenced this issue Sep 18, 2022
**_v2.8.4 (20220918)_**

**[Bug Fixes]**
 - [Bugfix] Handle gcc unsupported __VA_OPT___ macro (#1880 #1881)
crankyoldgit added a commit that referenced this issue Sep 18, 2022
**_v2.8.4 (20220918)_**

**[Bug Fixes]**
 - [Bugfix] Handle gcc unsupported `__VA_OPT___` macro (#1880 #1881)
@crankyoldgit
Copy link
Owner

v2.8.4 has been released which contains the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants