Skip to content

Commit

Permalink
Enable -Wpedantic flag on Android and use std::vector instead of …
Browse files Browse the repository at this point in the history
…VLA to pass arguments to `_scheduleOnJS` (#6157)

## Summary

Just wanted to enable `-Wpedantic` flag on Android like React Native
does.

## Test plan

Tested on runOnUI / runOnJS example.
  • Loading branch information
tomekzaw authored Jun 24, 2024
1 parent 29ff580 commit b4a8837
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "Shareables.h"
#include "WorkletRuntime.h"

#include <vector>

#ifdef ANDROID
#include "Logger.h"
#else
Expand Down Expand Up @@ -110,13 +112,11 @@ void WorkletRuntimeDecorator::decorate(
auto argsArray =
shareableArgs->toJSValue(rt).asObject(rt).asArray(rt);
auto argsSize = argsArray.size(rt);
// number of arguments is typically relatively small so it is ok to
// to use VLAs here, hence disabling the lint rule
jsi::Value args[argsSize]; // NOLINT(runtime/arrays)
std::vector<jsi::Value> args(argsSize);
for (size_t i = 0; i < argsSize; i++) {
args[i] = argsArray.getValueAtIndex(rt, i);
}
remoteFun.asObject(rt).asFunction(rt).call(rt, args, argsSize);
remoteFun.asObject(rt).asFunction(rt).call(rt, const_cast<const jsi::Value *>(args.data()), args.size());
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-reanimated/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_compile_options(${folly_FLAGS})

string(APPEND CMAKE_CXX_FLAGS " -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}")

string(APPEND CMAKE_CXX_FLAGS " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror")
string(APPEND CMAKE_CXX_FLAGS " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall -Wpedantic -Werror")

if(${IS_NEW_ARCHITECTURE_ENABLED})
string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
Expand Down

1 comment on commit b4a8837

@Bayramito
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tomekzaw , i think enabling -Wpedantic broke some things #6234 . Any solution ?

Please sign in to comment.