react-native-svg icon indicating copy to clipboard operation
react-native-svg copied to clipboard

Generated C++ code in react-native-svg contains invalid variable names using $

Open sriadimanav opened this issue 9 months ago • 4 comments

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

  1. Install package
  2. 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

sriadimanav avatar Mar 28 '25 15:03 sriadimanav

Don't have the repo right now, please check for the error This is coming directly after installing the package, during build time

sriadimanav avatar Mar 28 '25 15:03 sriadimanav

I have the same problem, during build time

EvertonPI avatar Mar 30 '25 13:03 EvertonPI

Same here, adding this library to a fresh new App created with RN CLI 0.78 version

sebackend avatar Apr 01 '25 05:04 sebackend

Hello, Same here, RN CLI 0.77 version

maryaibtissem avatar Apr 03 '25 10:04 maryaibtissem

same here "react-native": "0.79.1"

ymc-thzi avatar Apr 23 '25 07:04 ymc-thzi

same here "react-native": "0.78.2"

vaibhaw-innoraft avatar Apr 28 '25 01:04 vaibhaw-innoraft

the same here with 0.79.1

sdancer75 avatar Apr 29 '25 10:04 sdancer75

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?

WoLewicki avatar May 07 '25 14:05 WoLewicki

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.

sdancer75 avatar May 08 '25 07:05 sdancer75

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.

WoLewicki avatar May 08 '25 08:05 WoLewicki

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.

kankaristo avatar May 08 '25 08:05 kankaristo

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).

WoLewicki avatar May 08 '25 09:05 WoLewicki

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

kankaristo avatar May 08 '25 09:05 kankaristo

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!

WoLewicki avatar May 08 '25 10:05 WoLewicki