Add .clang-format file to icu4c source to unify the style among icu4c

Description

In order to unify the coding style of icu4c, I suggest adding .clang-format file that includes all the formatting styles that we agreed on for icu4c. Thus will help us to format our files easily by running clang-format tool.

Activity

Show:
Younies Mahmoud
October 8, 2020, 9:34 AM

yes

Shane Carr
September 30, 2020, 6:23 PM

There is a commit on this ticket shipping in ICU 68. Should the ticket be marked as fixed?

Hugo van der Merwe
June 3, 2020, 11:58 AM

“AllowShortBlocksOnASingleLine” is the option I’m most often going against - we’ve got it set to “SBS_Always”, I think we should at least consider whether we’d prefer “SBS_Empty” - particularly if we’ll encourage anyone to trust autoformatting (e.g. via git-clang-format).

The other thing I’m not trusting clang-format to take care of is documentation wrapping. We’ve got “ColumnLimit” set to 105, but I really strongly prefer documentation to be wrapped at 80 characters at most: easier to fit two code windows side-by-side and not have to scroll left/right in order to read. (Narrow columns are also easier to read, e.g. newspapers.)

Unfortunately I don’t see clang-format supporting different wrapping widths for code as for documentation. I’m wrapping docs with VSCode’s “rewrap” extension instead of letting clang-format take care of it.

Hugo van der Merwe
May 12, 2020, 11:14 AM

Looks like git-clang-format can automatically format only changed code. We could document this as a suggested workflow for those interested. I’ve commented about this on Younies' pull request too:

Hugo van der Merwe
April 6, 2020, 9:49 AM

Codingguidelines also found in the userguide-migration branch in the ICU repository:
docs/userguide/dev/codingguidelines.md
I guess any improvements go direclty here, userguide on Google Sites is now considered read-only AFAIR.

Fixed
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Younies Mahmoud

Reporter

Younies Mahmoud

Components

Priority

minor

Fix versions