-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Enforce asterisk alignment for C++ and ObjC pointers #4703
Enforce asterisk alignment for C++ and ObjC pointers #4703
Conversation
So far we've been using the default mode of prevailing-in-file, which means we aren't consistent within each language what mode we use. Now that clang-format can identify ObjC headers (which didn't used to be the case), we can enforce different styles for the two languages. This sets left-aligned for C++ to match the Flutter engine, and right-aligned for ObjC to match the prevaling Apple style.
@jmagman A lot more ObjC code here was using left-aligned than I expected. I assumed we'd want to follow Apple's usual style, but we could also use left-aligned for everything (or as I like to think of it "correct" 😁 ); I leave it entirely up to you. |
FWIW the google style guides for objc and c++ are agnostic to the placement of the asterisks. |
Google style is agnostic, but I've never been on a team that doesn't have a team-level convention for this in order to have local consistency. |
sgtm, whatever you all want to do. I renamed the PR since it sounded very scary, potentially having to do with memory alignment instead of code formatting =) |
🤷🏻 "pointer alignment" is the name of the clang-format setting. |
In the context of formatting code "pointer alignment" makes sense in the context of making changes to a codebase it is ambiguous and scary. I imaging someone investigating a mysterious crash and that PR title jumping out at them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmagman A lot more ObjC code here was using left-aligned than I expected. I assumed we'd want to follow Apple's usual style, but we could also use left-aligned for everything (or as I like to think of it "correct" 😁 ); I leave it entirely up to you.
Let's keep right-alignment to match the Apple style. As long as it's consistent, and better if a formatter can fix it for me, I can live with either.
LGTM
So far we've been using the default mode of prevailing-in-file, which
means we aren't consistent within each language what mode we use. Now
that clang-format can identify ObjC headers (which didn't used to be the
case), we can enforce different styles for the two languages.
This sets left-aligned for C++ to match the Flutter engine, and
right-aligned for ObjC to match the prevaling Apple style.
No version change: automated whitespace-only change with no actual effect on clients.
No CHANGELOG change: uninteresting mechanical change.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).