Use clang-format for c code?
mattldawson opened this issue · 9 comments
If we use clang-format for the .c
and .h
files it might make it easier to maintain consistency in coding style.
@mattldawson 's style for c code has drifted over time and @cguzman95 has his own style. We could consider using clang format and some automation for the c code to keep it a little cleaner.
I would propose that we only do this at a point where there are no open develop branches. It may make the subsequent merge harder. And, that we only apply it to the CAMP c files, not the ones in the PartMC master branch (for the same reason).
As we wait for a time when we could implement this, we could discuss what style everybody likes.
What do you guys think?
👍
Code formatters are great! Huge reduction in thought and friction.
Awesome! Are there any of these available for Fortan code? I'm not aware of any.
(side note - it's kind of fun talking in 3rd-hashtag)
Seems like there are some default styles we could use:
LLVM A style complying with the LLVM coding standards
Google A style complying with Google’s C++ style guide
Chromium A style complying with Chromium’s style guide
Mozilla A style complying with Mozilla’s style guide
WebKit A style complying with WebKit’s style guide
Microsoft A style complying with Microsoft’s style guide
I have no preference, and I can't think of anything special I really care about one way or another. What do you guys think? We also have the option of starting with one of these styles and modifying it, if there's something we would like to change.
Doing a fast review, I like the Google C++ style. At least the documentation is very clear and remarks the pros and cons. When there are no open development branches and we solve the major issues, we can analyze this deeply
Talking with @cguzman95 we decided to go ahead and try this now (with the Google style). It might actually make the merges easier because we can format the chem_mod
and develop-
branches before merging.
ok, I think this might be working now:
- there's a
partmc/.clang-format
file that's based on the Google c++ style with one slight modification to keep Travis happy - the
.c
files that are in themaster
branch have flags in them to keep them from being reformatted. we can change this later if we like how this works (after the great merge) - @cguzman95 - I put a
.clang-format
file in thepartmc/src/cuda
folder to prevent changes to your GPU code. Once you're ready to reformat them, you can remove the file and they'll be formatted the same as the other folders. (we might need to make some adjustments to include.cu
files in the reformatting.) - we can run
tool/format_code.sh
before we're ready to commit to reformat everything. - Travis will check the formatting, but it won't actually change anything, it will just fail (hopefully)
Okay I will check that format in the next issues