#endifpreprocessor directives shall reside in the same file as the
#ifdefdirective to which they are related.
#endifdirectives equal to or greater than 20 lines away from the
#ifdefdirective to which they are related shall be decorated by language comment indicating the conditional they are associated with.
#includedirectives in a file shall only be preceded by other preprocessor directives or comments.
#includedirectives shall use brace (“<”) and (“>”) style for all public headers, including C and C++ standard library, or other first- and third-party public library headers.
#includedirectives should use double quote (‘“‘) and (‘“‘) style for all private or relative headers.
#includedirectives should be grouped, ordered, or sorted as follows:
"openthread-core-config.h"should be the first header file included.
"openthread-core-config.h"before any other header file.
#if 0 ... #endifsemantics.
undefpreprocessor directive should be avoided and shall never be used to undefine a symbol from a foreign module.
OT_UNUSED_VARIABLEmacro at the top of a function or method before all local variable declarations.
using namespaceStatements in Headers
using namespacestatement should not be used outside of object scope inside header files.
OpenThread uses the
make pretty build target to reformat code and enforce code format and style. The
make pretty-check build target is included in OpenThread's continuous integration and must pass before a pull request is merged.
make pretty and
make pretty-check build targets require clang-format v6.0.0.
otprepended to their name.
gprepended to the name to denote global scope.
sprepended to the name to denote static scope.
mprepended to the name to denote member scope.
aprepended to the name to denote function parameter scope.
pylintover your code.
pylintis a tool for finding bugs and style problems in Python source code. It finds problems that are typically caught by a compiler for less dynamic languages like C and C++. Because of the dynamic nature of Python, some warnings may be incorrect; however, spurious warnings should be fairly infrequent.