Generated C++ code in react-native-svg contains invalid variable names using $
Description
Error Log
Task :app:buildCMakeDebug[x86]
C/C++: ninja: Entering directory `/Users/aditya/Documents/mock_app/android/app/.cxx/Debug/6u34i582/x86'
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:31:44: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 31 | void RNSVGImageEventEmitter::onLoad(OnLoad $event) const {
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:32:26: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 32 | dispatchEvent("load", [$event=std::move($event)](jsi::Runtime &runtime) {
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:32:43: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 32 | dispatchEvent("load", [$event=std::move($event)](jsi::Runtime &runtime) {
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:33:10: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 33 | auto $payload = jsi::Object(runtime);
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:36:40: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 36 | source.setProperty(runtime, "width", $event.source.width);
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:37:41: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 37 | source.setProperty(runtime, "height", $event.source.height);
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:38:38: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 38 | source.setProperty(runtime, "uri", $event.source.uri);
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:39:3: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 39 | $payload.setProperty(runtime, "source", source);
C/C++: | ^
C/C++: /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:41:12: warning: '$' in identifier [-Wdollar-in-identifier-extension]
C/C++: 41 | return $payload;
C/C++: | ^
C/C++: 9 warnings generated.
This is what I got from GPT
This is the same issue as before, now occurring in the x86 architecture build. The warnings indicate that the generated C++ code in react-native-svg contains invalid variable names using $, which is not allowed in standard C++.
Steps to reproduce
- Install package
- run react-native run-android
Snack or a link to a repository
https://snack.expo.dev/@expo.hoangdv/rn-svg-bug
SVG version
15.11.2
React Native version
0.78.1
Platforms
Android
JavaScript runtime
None
Workflow
React Native
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
Android emulator
Device model
No response
Acknowledgements
Yes
Don't have the repo right now, please check for the error This is coming directly after installing the package, during build time
I have the same problem, during build time
Same here, adding this library to a fresh new App created with RN CLI 0.78 version
Hello, Same here, RN CLI 0.77 version
same here "react-native": "0.79.1"
same here "react-native": "0.78.2"
the same here with 0.79.1
At the end it says 9 warnings generated. so it shouldn't be the reason of app not building. Or is this issue not about it?
At the end it says
9 warnings generated.so it shouldn't be the reason of app not building. Or is this issue not about it?
it is just a warning. The app will be builded despite of these warnings.
Ok so what is the purpose of this issue? I think those warnings come from things generated by codegen and don't have much to do with react-native-svg.
Ok so what is the purpose of this issue? I think those warnings come from things generated by codegen and don't have much to do with
react-native-svg.
Where are they coming from then? They don't happen if you don't have react-native-svg as a dependency, so definitely somehow related to it. Is there some other project that would be more appropriate for this issue?
Those warnings produce a lot of noise in build output, which can easily make it more difficult to see other important warnings/errors. I would prefer to maintain a zero warning build, if at all possible.
You can post it in react-native repo since it comes from codegen (see /build/generated/source/codegen in /Users/aditya/Documents/mock_app/node_modules/react-native-svg/android/build/generated/source/codegen/jni/react/renderer/components/rnsvg/EventEmitters.cpp:31:44).
Looks like a PR has already been merged that's related to this (or at least a very similar looking issue): https://github.com/facebook/react-native/pull/49792
The commit has a tag for v0.80.0-rc.0, so this might be fixed once React Native v0.80.0 is released:
https://github.com/facebook/react-native/commit/c4c3d3bfbe8af1071c26bcffe7bd4f5ab39b9554
Yeah, so I will close this issue since there is no action to be taken on the library side. Feel free to comment here and we can reopen it if I'm missing something!