Skip to content

[Codegen] Avoid reserved identifiers (__<method>) for C++ TurboModule invokers (#59843) - #59846

Open
Bahadir10 wants to merge 1 commit into
react:mainfrom
Bahadir10:fix/codegen-reserved-identifier-invoker
Open

Bahadir10 wants to merge 1 commit into
react:mainfrom
Bahadir10:fix/codegen-reserved-identifier-invoker

Conversation

@Bahadir10

Copy link
Copy Markdown

Summary

Fixes #59843

The C++ spec header generated by @react-native/codegen (GenerateModuleH.js) declares each method's static invoker as __<methodName> and registers it under that name in methodMap_. Identifiers beginning with a double underscore are reserved to the implementation under the C++ standard ([lex.name]/3). When a library compiles its sources with clang's -Wreserved-identifier and -Werror, it fails to compile the generated <Module>JSI.h.

This PR renames the static invoker prefix from __ to invoke_ (e.g. invoke_<methodName>), ensuring generated headers do not declare reserved identifiers while keeping the methodMap_ dispatch key, parameter types, and arity unchanged.

Changelog

[General][Fixed] - Prevent C++ TurboModule codegen from using reserved identifiers (__<method>) for invokers

Test Plan

  • Verified generated C++ header output and snapshots (GenerateModuleH-test.js.snap).
  • Invoker names are generated as invoke_<method> instead of __<method>.

Summary:
**Problem**: The C++ spec header generated by `@react-native/codegen` declares each method's static invoker as `__<methodName>` and registers it under that name in `methodMap_`. Identifiers beginning with a double underscore are reserved to the implementation under the C++ standard ([lex.name]/3). When a library compiles with clang's `-Wreserved-identifier` and `-Werror`, it fails to compile the generated `<Module>JSI.h`.

**Proposed change**: Change the invoker identifier prefix from `__` to `invoke_` in `GenerateModuleH.js` so that invokers (e.g. `invoke_<methodName>`) do not use reserved identifiers.

Fixes react#59843

Changelog:
[General][Fixed] - Prevent C++ TurboModule codegen from using reserved identifiers (`__<method>`) for invokers
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 7, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++ TurboModule codegen names each method's invoker with a reserved identifier (__<method>)

1 participant