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

[libstdc++] Update avr libstdc++ submodule to C++20 version #535

Merged
merged 7 commits into from
Jan 10, 2021

Conversation

chris-durand
Copy link
Member

Fix submodule commit

@chris-durand
Copy link
Member Author

modm/src/modm/platform/i2c/i2c_master.hpp:81:34: error: 'floorf' is not a member of 'std'; did you mean 'floor'?
   81 |   constexpr float pre_raw = std::floorf(pre_part_raw) < 8 ? 0 : (pre_part_raw - 8) / pre;

It's correct that it doesn't work. libstdc++ does not provide std::*f C99 math functions in the std namespace, this is a gcc bug. Nasty macros in the AVR math.h C header like #define floorf floor made std::floorf accidentally compile. To fix a math function issue I undefined the macros in avr-libstdc++ <cmath> and replaced them with proper functions. Now the code above does not compile anymore.

To keep consistency between platforms I will not add the float variants but fix the modm AVR code to use the proper C++ native overloads.

libstdc++ does not provide overloads like std::floorf.
A bug due to a macro made this compile accidentally before.
@chris-durand
Copy link
Member Author

The CI passes now, but there is still an issue to be fixed. Some math functions are still missing in namespace std but they are not used within the modm codebase. I'll add a test to trigger the problem.

@salkinium salkinium merged commit 038657c into modm-io:develop Jan 10, 2021
@chris-durand chris-durand deleted the update_avr-libstdc++20 branch January 2, 2022 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants