-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
portGET_ARGUMENT_COUNT() defintion broken for C++ (IDFGH-4021) #5897
Comments
This also breaks |
Here is a working portGET_ARGUMENT_COUNT() (named as portGET_ARGUMENT_COUNT_ALT). Tested with C, C++, C++11, C++17. |
Thanks for reporting, we will look into. |
@seijikun The code you posted seems to be for x86/x64 gcc? In IDF, the main function is called
The example you posted is C++17 code, while IDF currently always uses C++11. It seems not very likely but maybe that's the reason. Could you try to change the reproducing code so that it can be compiled for the ESP32 while exposing the error? |
Yes. I thought, that the preprocessor should work the same everywhere. Here is my simplified project, where the error occurs: I am building with ESP-IDF Master (8bc19ba893e5544d571a753d82b44a84799b94b1):
|
@seijikun Thanks! I can reproduce the error. Will have a look. Please keep in mind that we don't currently support any other standard than C++11. |
@seijikun I switched it back to C++11 and it works (by commenting the line in the |
@0xjakob When I completely remove the |
Ahh, sorry! We actually use |
Ah! |
This probably means that we don't need to support the variadic form of Edit: disregard, I have missed #5897 (comment). |
@igrr is there a need to have the variadic form outside of the test compilation mode? I'm thinking not since all usages of the macro outside of the isr latency test are of the simple no argument form. Also the snippet I provided above that works for various c++ versions is quite ugly as it pollutes the global namespace with a number of extra defines. It would be best to centralize that with include guards to prevent redefinition warnings and general namespace pollution. |
@atanisoft No need in IDF, but we made this improvement to make such logic unnecessary for third party projects: https://github.com/hathach/tinyusb/blob/7d2fc124452d6ec2d5d45bdacc4fc8b38d03d0d0/src/osal/osal_freertos.h#L70-L74. |
@igrr There are a few macros like this that are inconsistent between ports... Another is portENTER_CRITICAL where most ports do not take an argument, perhaps that can also be similarly fixed using a core specific |
That's a good point, it looks feasible at first glance. Would you mind opening a new issue so that we can track this? |
|
This seems also to happen with current arduino-esp32 . |
Are you trying to use arduino-esp32 1.0.4 (or 1.0.5) against IDF 4.x? If so, it won't work. You will need to move up to the arduino-esp32 esp32s2 branch and use IDF 4.2+. |
I think am using the latest arduinoesp32 based on idf 4.2. I have just written a little utility to check revisions and compatibility: #!/bin/bash
echo components/arduino revision is:
git -C components/arduino rev-parse --short HEAD
echo
echo arduino revision and esp-idf revision should match:
git -C $IDF_PATH rev-parse --short HEAD
awk '/CONFIG_ARDUINO_IDF_COMMIT/{gsub("\"","");print $3}' < components/arduino/tools/sdk/esp32/include/config/sdkconfig.h Result:
|
Are you on the esp32s2 branch or another branch of arduino-esp32? |
I do not see a different branches for esp32 or esp32-s2 . Could you please provide commit number or check the commit number above? |
The esp32s2 branch is compatible for both esp32 and esp32s2, it has since been renamed though: https://github.com/espressif/arduino-esp32/tree/idf-release/v4.2 |
Yes, commit 93c6226 is the latest commit on the above - 2 dyes ago. |
@qt1 make sure you are using the GNU extensions for C++11 or later, ie:
There is an issue with using -std=c++14 (or any version really). |
It seems like the code uses an old gcc hack namely IMHO forcing the user to a specific version just to bypass a bug sounds kind of wrong.. In any case, it seems like the newest version v4.2 does not include either macros. I would suggest to update arduino-esp32 to the newest release, and avoid this issue altogether.. |
@qt1 arduino-esp32 is using the 4.2 branch of esp-idf on the 4.2 branch of arduino-esp32. Master uses 3.3. In both cases it uses gnu++11 and not later as that is what esp-idf uses/supports. But I do agree, it seems hacky. Esp-idf master has moved up to FreeRTOS 10.x and is still in flux as there are many customized pieces for multi-core support |
ESP-IDF has a macro expansion issue for __VA_RAGS__ when gnu compiler extension is disabled. The esp32 build fails with xtensa-esp32-elf-c++ 8.4.0 because of espressif/esp-idf#5897
espressif/esp-idf#5897 portGET_ARGUMENT_COUNT() defintion broken for C++ (IDFGH-4021)
Environment
git describe --tags
to find it): v4.3-dev-1197-g8bc19ba89xtensa-esp32-elf-gcc --version
to find it): xtensa-esp32-elf-gcc (crosstool-NG esp-2020r3) 8.4.0Problem Description
The macro
portGET_ARGUMENT_COUNT()
in portmacro.h line 331 seems to be broken when used with C++.Have a look at the demonstration here. With
0
arguments, it returns1
instead of0
. This triggers the first static assertion directly below the definition:As can be seen here, this works when instead run with C.
Code to reproduce this issue
Log
I am using a main.cpp in my main component. The include tree looks as follows:
Am I doing something wrong here?
The text was updated successfully, but these errors were encountered: