Formatting #207
Replies: 9 comments 19 replies
-
4 Spaces for Indentation instead of 2 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Arguments should not be one-per-lineSome styles require that each argument be on its own line in the function definition and/or call. I like this generally for definitions but not for calls. I would also argue that this is made totally irrelevant if we have doxygen documentation for each function since that removes the need for the definition arguments to be easily readable or easy to add comments next to. |
Beta Was this translation helpful? Give feedback.
-
Votes for Google C++ |
Beta Was this translation helpful? Give feedback.
-
Votes for Mozilla C++ |
Beta Was this translation helpful? Give feedback.
-
Votes for LLVM C++ |
Beta Was this translation helpful? Give feedback.
-
Long Comment Lines for SeparationLines like this to separate functions // ===================================================================
void func1(args)
{
stuff
}
// ===================================================================
// ===================================================================
void func2(args)
{
stuff
}
// =================================================================== |
Beta Was this translation helpful? Give feedback.
-
Consecutive Assignments Should be Aligned// This
int aaaa = 12;
int b = 23;
int ccc = 23;
#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define foo(x) (x * x)
#define bar(y, z) (y + z)
// Not this
int aaaa = 12;
int b = 23;
int ccc = 23;
#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define foo(x) (x * x)
#define bar(y, z) (y + z) |
Beta Was this translation helpful? Give feedback.
-
See the Cholla Wiki for a summary of this discussion: https://github.com/cholla-hydro/cholla/wiki/Making-a-Pull-Request |
Beta Was this translation helpful? Give feedback.
-
Summary
This is where we'll discuss our preferences for a unified formatting scheme in Cholla.
See the Style Wars Discussion for emoji response conventions.
To keep voting organized, make each choice a Comment on the Discussion. The top level Comments should all be voting options or a neutral introduction to the topic. Debates should all happen in Replies: general replies under the neutral introduction, option-specific pros/cons under their vote Comment.
Thus the hierarchy is as follows: Discussions (for each issue), Comments (for each option), Replies (for each pro/con)
Formatting Choices
Here is a selection of code from Cholla, and a default example, of three of the default choices that
clang-format
comes with. I chose these three to line up with what is being discussed in the naming discussion with the substitution of LLVM for Chromium since the Chromium format was almost identical to the Google formatCode was chosen from Cholla to represent various common cases and those cases are separated by large block comments. I apologize that my own code is overrepresented, some of that is by request of others but mostly I just knew where to find the examples I was looking for in my own code. If there's any piece of code you want to see in any format you can use the clang-format configurator.
current.cpp.txt
google.cpp.txt
LLVM.cpp.txt
mozilla.cpp.txt
Beta Was this translation helpful? Give feedback.
All reactions