Repository navigation
Description
Description
The C++ spec header the codegen writes for a C++ TurboModule declares each method's static invoker as __<methodName> and registers it under that name in methodMap_. An identifier that starts with a double underscore is reserved to the implementation ([lex.name]/3, https://eel.is/c++draft/lex.name#3), so a library that compiles its own sources with clang's -Wreserved-identifier cannot include its own generated <Module>JSI.h under the -Werror React Native's build flags carry.
The names come from packages/react-native-codegen/src/generators/modules/GenerateModuleH.js on main (f480836):
- line 622:
static jsi::Value __${prop.name}(jsi::Runtime &rt, TurboModule &turboModule, …) - line 187:
methodMap_["${methodName}"] = MethodMetadata {.argCount = ${paramCount}, .invoker = __${methodName}};
Expected: the generated header declares and registers each invoker under a name outside the reserved set, for example invoke_${prop.name}, with the methodMap_ key, the arity and the call into the module unchanged, so a header that compiles today still compiles.
Steps to reproduce
- Clone the reproducer below.
ReproducerApp/specs/NativeSample.tsis a TurboModule spec with one method,add(left: number, right: number): number. - Run its
repro.shin anode:24container with clang:It installsdocker run --rm -v "$PWD:/repro:ro" node:24 bash -c \ 'apt-get update -qq && apt-get install -y -qq clang libboost-dev libdouble-conversion-dev libgoogle-glog-dev > /dev/null && bash /repro/repro.sh'
react-native@nightly, generates the spec with@react-native/codegen'scombine-js-to-schema-cli.jsandreact-native/scripts/generate-specs-cli.js --platform ios --libraryType modules, and compiles the generatedSampleJSI.hwithclang++ -std=c++20 -fsyntax-only -Werror -Wreserved-identifier, readingReactCommonand the folly, fmt and fast_float releases React Native pins as system headers. - Expected: the header compiles. Actual: clang refuses the generated invoker:
./out/SampleJSI.h:29:21: error: identifier '__add' is reserved because it starts with '__' [-Werror,-Wreserved-identifier] SUMMARY: react-native 0.90.0-nightly-20261107-3aed1720f's codegen names the module's invokers with reserved identifiersbash /repro/repro.sh 0.88.1shows the same on the latest stable.
React Native Version
0.88.1
Affected Platforms
Build - Linux
Output of npx @react-native-community/cli info
System:
OS: Linux 6.18 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (24) x64 AMD Ryzen 9 9950X3D 16-Core Processor
Memory: 120.26 GB / 125.63 GB
Shell:
version: 5.2.15
path: /bin/bash
Binaries:
Node:
version: 24.22.2
path: /usr/local/bin/node
Yarn:
version: 1.22.22
path: /usr/local/bin/yarn
npm:
version: 11.19.1
path: /usr/local/bin/npm
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: Not Found
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react: Not Found
react-native:
installed: 0.90.0-nightly-20261107-3aed1720f
wanted: ^0.90.0-nightly-20261107-3aed1720f
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
== generate the module's C++ spec
generated out/SampleJSI.h
25: methodMap_["add"] = MethodMetadata {.argCount = 2, .invoker = __add};
29: static jsi::Value __add(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
== compile the spec with -Werror -Wreserved-identifier
./out/SampleJSI.h:29:21: error: identifier '__add' is reserved because it starts with '__' [-Werror,-Wreserved-identifier]
1 error generated.
SUMMARY: react-native 0.90.0-nightly-20261107-3aed1720f's codegen names the module's invokers with reserved identifiers
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/react-native-codegen-reserved-invoker-names
Screenshots and Videos
No response
Activity