We generally follow Google C++ Style Guide.
Variable names should consist of lowercase words connected by underscores, e.g.
llvm_context
.Class and struct names should consist of words with first letters capitalized, e.g.
CodegenLLVM
.Macros should be capital start with
TI
, such asTI_INFO
,TI_IMPLEMENTATION
.- We do not encourage the use of macro, although there are cases where macros are inevitable.
Filenames should consist of lowercase words connected by underscores, e.g.
ir_printer.cpp
.
- Use
auto
for local variables when appropriate. - Mark
override
andconst
when necessary.
C language legacies:
printf
(Usefmtlib::print
instead).new
andfree
. (Use smart pointersstd::unique_ptr, std::shared_ptr
instead for ownership management).#include <math.h>
(Use#include <cmath>
instead).
Exceptions (We are on our way to remove all C++ exception usages in Taichi).
Prefix member functions with
m_
or_
.Virtual function call in constructors/destructors.
NULL
(Usenullptr
instead).using namespace std;
in the global scope.typedef
(Useusing
instead).
- Please run
ti format