Change rad2deg function to static#2924
Open
zayfen wants to merge 1 commit intosoftware-mansion:mainfrom
Open
Conversation
1. rad2deg is a very common function name and can easily cause duplicate definition errors. 2. rad2deg is only used within this file, so it should be declared as static.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rad2degis a very common utility function name and can easily cause duplicate symbol definition errors when linking against third-party static libraries (.afiles) that happen to define a function with the same name.rad2degis only used withinRNSVGMarkerPosition.mmitself, so there is no reason for it to have external linkage. Declaring itstaticrestricts its visibility to the translation unit, which:Impacted area: iOS/macOS marker rendering (
RNSVGMarkerPosition.mm).Test Plan
Prerequisites
react-native-svgalongside a third-party static library that also definesrad2degSteps to reproduce the original issue
.a) that exports arad2deg(double)symbol to your React Native iOS project.xcodebuild— the build will fail with:duplicate symbol 'rad2deg(double)' in: libRNSVG.a (RNSVGMarkerPosition.o) .a (...) ld: 1 duplicate symbols clang: error: linker command failed with exit code 1
Verification after fix
yarn ios --device.Compatibility
Checklist
I have tested this on a device and a simulator
I added documentation in
README.mdI updated the typed files (typescript)
I added a test for the API in the
__tests__folderI have tested this on a device and a simulator
I added documentation in
README.mdI updated the typed files (typescript)
I added a test for the API in the
__tests__folder