-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Host tests: different Arduino.h contents #7359
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
Comments
@mcspr do you intend to propose a PR ? |
Yes. I have a somewhat working POC with only a cores/esp8266/Arduino.h, just need some time to actually push it Significant issue with std::abs <-> abs is still there for me, not really sure why cstdlib / stdlib.h / Arduino.h decides to be included in a different order in mocks and in real hardware builds... But, more in the PR itself, with some code examples. |
What happens in mock does not follow any official rule. Bend it if you can, to comply with arduino. |
For the specific issue with abs, problem is with compiler versions. Even with 7.5.0 used by the CI, the following example based on the Arduino.h assumptions is invalid. extern "C" {
#include <stdlib.h>
#include <stdio.h>
}
#undef abs
#define abs(x) ((x > 0) ? (x) : -(x))
#include <algorithm>
int main() {
printf("%d\n", std::abs(-1));
} ~> g++ --version
g++ (GCC) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~> g++ -c -o example.o example.cpp
example.cpp: In function ‘int main()’:
example.cpp:6:16: error: expected unqualified-id before ‘(’ token
6 | #define abs(x) ((x > 0) ? (x) : -(x))
| ^
example.cpp:10:25: note: in expansion of macro ‘abs’
10 | printf("%d\n", std::abs(-1));
| ^~~
~> ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-g++ --version
xtensa-lx106-elf-g++ (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~> ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-g++ -c -o example.o example.cpp
~> # builds just fine GCC 10 PR already exposed this issue, because it includes |
Basic Infos
Platform
Problem Description
As noticed in the #6294 , host tests Arduino.h should be in sync with the one used to build the real firmware.
MCVEThis does not cause any immediate issues, just introduces different build settings for host. Some (but not all) examples are:
#include <cmath>
This may cause more problems in the future, perhaps both headers should use the common source and adjust platform-specific settings.
The text was updated successfully, but these errors were encountered: