c-code-style icon indicating copy to clipboard operation
c-code-style copied to clipboard

cfg AStyle formatter does not fix all the conventions

Open cnrabdullah opened this issue 4 years ago • 3 comments

I tried using the astyle-code-format.cfg file with style but it almost only fixes indents and braces. I like the rules you described for variable and function naming but I couldn't find a way to format my C files according to that. There is no such option in AStyle. So even if I use your cfg file with AStyle, there is no difference between using yours or a predefined XML file on Eclipse (like original K&R etc.)

cnrabdullah avatar Dec 02 '20 15:12 cnrabdullah

Original K&R + adding tabs to spaces is the way to go with my rules written here.

MaJerle avatar Dec 02 '20 15:12 MaJerle

Do you mean the Original K&R has the same naming rules as you described like having all lowercase letters for example? If yes, then there is no option in AStyle or Eclipse's Formatter to re-format them I guess? If yes, do you have any suggestions on that? We have a couple of libraries provided by different manufacturers and we want to use the same formatting on them.

cnrabdullah avatar Dec 02 '20 15:12 cnrabdullah

K&R does not have naming rules and it won't change variable name or declaration order as per my style. So it means that you cannot 100% automate your code with AStyle, some things would need to be properly written manually.

MaJerle avatar Dec 04 '20 15:12 MaJerle

the style is a convention for code maintaining, consistency is paramount. and if this convention harm your code maintaining then relinquish it.

Princess-Sunset-Shimmer avatar Dec 05 '23 12:12 Princess-Sunset-Shimmer

邮件已收到,我会尽快回复的!

EmbeddedLife615 avatar Dec 05 '23 13:12 EmbeddedLife615

It is not advised to use astyle anymore. Clang-format is preferred way.

MaJerle avatar Dec 05 '23 13:12 MaJerle