We conform to Google C++ Style Guidelines. In particular:
- For C/C++, we use
.c/.ccand.hfor source files and header files, respectively. - Each line of code should not exceed 100 characters.
- Source files are organised by the functionality they implement, so a directory includes both the header and source files;
- All Noname code must be wrapped in the
nonamenamespace; - Each component further has its own namespace, under
noname; - Each source file should start with the copyright and licence notice.
- No importing or aliasing (
using) of namespace at all. - Use
CHECK_EQ/NEinstead ofCHECK(a == b)/(a != b). - When it comes to integer types, prefer
uint64_t,uint32_t,uint16_t,uint8_t. - For indentation, each tab is strictly 2 characters and should be "expanded" to become spaces.
CamelCasefor class, struct, function and method names.snake_casefor local variables and member variables.kConstantorUPPER_SNAKE_CASEfor constants.- Logging/output should be done using glog instead of
std::cerrorstd::cout. - For debug-time only logs/output, use
DLOG(...);LOG(...)otherwise. - Test cases should be written using GTest.
- Command-line parameters should use GFlags.
- Knobs/parameters for each component should be defined in
src/config/config.ini. The build system will auto-generate the correspondingconfig.h. See more details under the "Parameters" section below. - No extra space, e.g., for casting use
reinterpret_cast<uint32_t>(...)rather thanreinterpret_cast<uint32_t> (...). - Use
structrather thanclass, for easier testing.
You may use "clang-format --style=Google" to make sure your code conforms to them.