software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.66k stars 1.27k forks source link

error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] #6005

Closed kien091 closed 2 months ago

kien091 commented 2 months ago

Description

I have error like this:

C:\Users\ASUS\AppData\Local\Android\Sdk\ndk\27.0.11718014\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=i686-none-linux-android23 --sysroot=C:/Users/ASUS/AppData/Local/Android/Sdk/ndk/27.0.11718014/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Dreanimated_EXPORTS -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/AnimatedSensor" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/Fabric" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/hidden_headers" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/LayoutAnimations" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/NativeModules" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/ReanimatedRuntime" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/Registries" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/SharedItems" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/../Common/cpp/Tools" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/android/src/main/cpp" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native/ReactCommon" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native/ReactCommon/callinvoker" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native/ReactCommon/react/renderer/graphics/platform/cxx" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native/ReactCommon/runtimeexecutor" -I"D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native/ReactCommon/yoga" -isystem C:/Users/ASUS/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/folly_runtime/include -isystem C:/Users/ASUS/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/glog/include -isystem C:/Users/ASUS/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/jsi/include -isystem C:/Users/ASUS/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/reactnativejni/include -isystem C:/Users/ASUS/.gradle/caches/transforms-4/c7e26f7d3c2fc1a6636ff1467fc77795/transformed/jetified-fbjni-0.6.0/prefab/modules/fbjni/include -isystem C:/Users/ASUS/.gradle/caches/transforms-4/e7689cf58141a18272e612b148cefd59/transformed/jetified-hermes-android-0.74.1-debug/prefab/modules/libhermes/include -isystem C:/Users/ASUS/.gradle/caches/transforms-4/441abbc29e7844d504dda1a0ffede014/transformed/jetified-react-android-0.74.1-debug/prefab/modules/hermes_executor/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -DREACT_NATIVE_MINOR_VERSION=74 -DREANIMATED_VERSION=3.10.1 -DHERMES_ENABLE_DEBUGGER=1 -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++20 -Wall -Werror -DJS_RUNTIME_HERMES=1 -fno-limit-debug-info -fPIC -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_HAVE_XSI_STRERROR_R=1 -std=gnu++20 -MD -MT CMakeFiles/reanimated.dir/baa741105af35d3bc45a19e61592e3fd/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp.o -MF CMakeFiles\reanimated.dir\baa741105af35d3bc45a19e61592e3fd\Common\cpp\ReanimatedRuntime\WorkletRuntimeDecorator.cpp.o.d -o CMakeFiles/reanimated.dir/baa741105af35d3bc45a19e61592e3fd/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp.o -c "D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp"

D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp:115:29: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
115 | jsi::Value args[argsSize]; // NOLINT(runtime/arrays)
| ^~~~~~~~
D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp:115:29: note: read of non-const variable 'argsSize' is not allowed in a constant expression
D:/Final Cross-Platform/ElectronicsStore/node_modules/react-native-reanimated/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp:112:18: note: declared here
112 | auto argsSize = argsArray.size(rt);
| ^

. I'm newbie in react native & i try to make drawer navigation. When i install react-native-reanimated I see this error. I spend 2 days for this. How can i fix it?

Steps to reproduce

  1. I'm install react-native-reanimated to make drawer navigation but i see this error
  2. Just run with metro like npx react-native run-android i will see this error
  3. I try to fix it in 2 days and i can't fix it.

Snack or a link to a repository

https://github.com/kien091/electronics-app.git

Reanimated version

3.11.0

React Native version

0.74.1

Platforms

Android

JavaScript runtime

None

Workflow

React Native

Architecture

Paper

Build type

None

Device

Android emulator

Device model

No response

Acknowledgements

Yes

szydlovsky commented 2 months ago

Hey @kien091, first off - you don't have reanimated babel plugin in your repro's babel.config.js Please follow Reanimated installation guide and make sure it is there. Let me know if it changes anything

Malik-Adil commented 2 months ago

@szydlovsky I am facing the same issue and this is my babel.config.js module.exports = { presets: ['module:@react-native/babel-preset'], plugins: [ 'react-native-reanimated/plugin', ], };

szydlovsky commented 2 months ago

Hey @kien091 @Malik-Adil I think I got the fix and it is not connected to Reanimated whatsoever. The NDK version in your linked project is ndkVersion = "27.0.11718014", which is way too high for react native. Try changing it to, for example, NDK 23.