...
- Indentation levels are two columns.
- There is no hard line length limit.
- Tabs are not allowed in code. Set your editor accordingly. (Emacs:
(setq-default indent-tabs-mode nil)
.) - Use braces around substatements. (Relaxable for extremely simple substatements on the same line.)
- Use good taste to break lines and align corresponding tokens on adjacent lines.
- Use spaces around operators, especially comparisons and assignments. (Relaxable for boolean expressions and high-precedence operators in classic math-style formulas.)
- Put spaces on both sides of control flow keywords
if
,else
,for
,switch
, etc. * Use extra parentheses in expressions whenever operator precedence seems doubtful. Always use parentheses in shift/mask expressions (<<
,&
,|
, { ~}). - Use more spaces and blank lines between larger constructs, such as classes or function definitions.
- If the surrounding code has any sort of vertical organization, adjust new lines horizontally to be consistent with that organization. (E.g., trailing backslashes on long macro definitions often align.)
- Otherwise, use normal conventions for whitespace in C.
- Try not to change whitespace unless it improves readability or consistency. (Different editors indent differently, and spurious indentation changes will just make integrations more difficult.)
...
- Conform new code to style conventions. Avoid unnecessary "esthetic" variations, which are distracting.
- Use the C++ RAII design pattern to manage bracketed critical sections. See class
ResourceMark
for an example. +Verbose
is used to provide additional output for another flag, but does not enable output by itself.- Do not use ints or pointers as booleans with
&&
,||
,if
,while
. Instead, compare explicitly!= 0
or!= NULL
, etc. (See #8 above.) - Use functions from
globalDefinitions.hpp
when performing bitwise operations on integers. Do not code directly as C operators, unless they are extremely simple. (Examples:round_to
,is_power_of_2
,exact_log2
.) - Naming JTreg tests
- More suggestions on factoring.
...
Overview
Content Tools
ThemeBuilder