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:#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.using namespace Statements in Headersusing namespace statement should not be used outside of object scope inside header files.dynamic_cast and typeid.OpenThread uses script/make-pretty to reformat code and enforce code format and style. script/make-pretty check is included in OpenThread's continuous integration and must pass before a pull request is merged.
script/make-pretty requires clang-format v14.0.0 for C/C++ and yapf for Python.
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.