Skip to content
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

C++/C Source Code Formatting #657

Open
Gemba opened this issue May 20, 2020 · 2 comments
Open

C++/C Source Code Formatting #657

Gemba opened this issue May 20, 2020 · 2 comments

Comments

@Gemba
Copy link

Gemba commented May 20, 2020

I am proposing some suggestions for the source code formatting.

Rationale here.
Used tools and configs here.

Again, these are suggestions and do not be ment cast in stone atm. I would be happy to have some consensus on code formatting to make everyones life (maintainers and contributors) easiser with an unified code style. When agreed on, everyone can use the set.

I am filing an issue because it may be easier to track the changes.

The differences to the default settings uncrustify/universalindentgui uses are:

eat_blanks_after_open_brace=true
eat_blanks_before_close_brace=true
indent_case_shift=0
indent_columns=4
indent_switch_case=4
indent_with_tabs=0
input_tab_size=4
mod_add_long_ifdef_else_comment=16
mod_add_long_ifdef_endif_comment=16
mod_full_brace_do=add
mod_full_brace_for=add
mod_full_brace_function=add
mod_full_brace_if=add
mod_full_brace_using=add
mod_full_brace_while=add
mod_full_paren_if_bool=true
mod_remove_empty_return=true
mod_remove_extra_semicolon=true
nl_after_brace_close=true
nl_after_brace_open=true
nl_assign_leave_one_liners=true
nl_brace_else=remove
nl_brace_while=remove
nl_class_brace=add
nl_class_leave_one_liners=true
nl_do_brace=remove
nl_else_brace=remove
nl_elseif_brace=remove
nl_else_if=remove
nl_end_of_file=add
nl_enum_leave_one_liners=true
nl_fcall_brace=remove
nl_for_brace=remove
nl_func_leave_one_liners=true
nl_getset_leave_one_liners=true
nl_if_brace=remove
nl_if_leave_one_liners=true
nl_start_of_file=remove
nl_switch_brace=remove
nl_while_brace=remove
output_tab_size=4
pos_arith=lead
pos_bool=lead
pos_conditional=lead
sp_after_assign=force
sp_after_cast=remove
sp_after_operator=add
sp_after_sparen=add
sp_arith=add
sp_assign=add
sp_before_assign=force
sp_before_sparen=add
sp_bool=add
sp_brace_else=force
sp_compare=add
sp_cond_colon=add
sp_cond_question=add
sp_else_brace=force
sp_enum_assign=add
sp_inside_paren=remove
sp_inside_sparen=remove
sp_paren_paren=remove
sp_sparen_brace=add

@Gemba
Copy link
Author

Gemba commented May 19, 2021

Was rethinking this. Maybe clang-format is easier to use (also available as extension for Visual Studio) and it has some ready-made formatting templates which are well known in the open source community.

Will also reduce the stress on PRs regarding formatting (for the reviewer and submitter).

@nlsdg
Copy link

nlsdg commented Jun 6, 2021

Consider adding .editorconfig as well.
Many editors support it. While the number of supported properties is nowhere near the level of clang-format, its wide support would mean more editors would be able to at least get the basics enforced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants