-
Notifications
You must be signed in to change notification settings - Fork 25k
fix(android): replace std::format with std::to_string in graphicsConversions.h for C++17 compatibility #55112
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
base: main
Are you sure you want to change the base?
Conversation
Fix build crash on windows 11
|
Hi @shubhamd99! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
I don't think this is the right fix. React Native should build with C++20. |
We do already build with C++20 on Android: react-native/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake Line 17 in 0cda10b
so I'm unsure what this fix is about @shubhamd99 |
not able to build with std::format in android in windows 11, its throwing error during gradlew run |
Summary
This patch fixes a build failure on Android in React Native 0.83 caused by the use of
std::formatinreact/renderer/core/graphicsConversions.h. Android builds use C++17 and the Android NDK does not supportstd::format(a C++20 feature), which leads to compile/link errors (e.g., undefined symbol and missingstd::formaton Windows and other environments).The problematic line has been replaced with a C++17-compatible implementation using
std::to_string + "%".Motivation
std::formatis not available in the Android NDK’s C++17 toolchain.0.83 and potentially other versions that include this code.
This commit resolves the issue by using a supported alternative that produces the same result.
Changes
File:
ReactCommon/react/renderer/core/graphicsConversions.hBefore:
Summary:
Changelog:
Test Plan: