Skip to content

Rename enum constants in ObjC proto code if they would clash with reserved names. #2461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Apr 4, 2025

Rename enum constants in ObjC proto code if they would clash with reserved names.

Previously the code just didn't emit a constant at all. Now, we do emit one, but with an extra underscore. For example, if the enum constant is OVERFLOW, which collides with a macro in /usr/include/math.h, we'll output OVERFLOW_ instead. So client code can still reference it, albeit a little clumsily.

Eventually we should change the hardcoded list of reserved names to use the same reserved names list that the j2objc translator uses.

…erved names.

Previously the code just didn't emit a constant at all. Now, we do emit one, but with an extra underscore. For example, if the enum constant is `OVERFLOW`, which collides with a macro in `/usr/include/math.h`, we'll output `OVERFLOW_` instead. So client code can still reference it, albeit a little clumsily.

Eventually we should change the hardcoded list of reserved names to use the same [reserved names list](https://github.com/google/j2objc/blob/master/translator/src/main/resources/com/google/devtools/j2objc/reserved_names.txt) that the j2objc translator uses.

PiperOrigin-RevId: 743258491
@copybara-service copybara-service bot changed the title Rename enum constants in ObjC code if they would clash with reserved names. Rename enum constants in ObjC proto code if they would clash with reserved names. Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant