setjmp
or longjmp
.#else
, #elif
, and #endif
preprocessor directives shall reside in the same file as the #if
or #ifdef
directive to which they are related.#endif
directives equal to or greater than 20 lines away from the #if
or #ifdef
directive to which they are related shall be decorated by language comment indicating the conditional they are associated with.#include
directives in a file shall only be preceded by other preprocessor directives or comments.#include
directives shall use brace (“<”) and (“>”) style for all public headers, including C and C++ standard library, or other first- and third-party public library headers.#include
directives should use double quote (‘“‘) and (‘“‘) style for all private or relative headers.#include
directives should be grouped, ordered, or sorted as follows:"openthread-core-config.h"
should be the first header file included..c
or .cpp
file:"openthread-core-config.h"
before any other header file.#if 0 ... #endif
semantics.undef
preprocessor directive should be avoided and shall never be used to undefine a symbol from a foreign module.uint8_t
, int8_t
, etc.const
qualifier.const
qualifier.OT_UNUSED_VARIABLE
macro at the top of a function or method before all local variable declarations.using namespace
Statements in Headersusing namespace
statement should not be used outside of object scope inside header files.dynamic_cast
and typeid
.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.
The make pretty
and make pretty-check
build targets require clang-format v6.0.0.
ot
prepended to their name.g
prepended to the name to denote global scope.s
prepended to the name to denote static scope.m
prepended to the name to denote member scope.a
prepended to the name to denote function parameter scope.pylint
over your code. pylint
is 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.