Agora
1.2.0
Agora project
|
clang-format
. Running clang-format -i *.cc *.h
will format source and header files in the current directory to match Agora's code style. There are also editor plugins for clang-format
(example). We recommend using clang-format version 11 or above.lower_camel_case
for variable names.UpperCamelCase
for class, struct, and function names.kConstant
for static storage duration constants. Otherwise the usual variable nameing rules apply..cc
, header file names in .h
.const
, private
, or static
.Avoid macros unless absolutely necessary. For example, macros are acceptable to disable compilation of files that depend on proprietary libraries. So instead of:
#ifdef USE_LDPC std::string raw_data_filename = x; #else std::string raw_data_filename = y; #endif
prefer:
std::string raw_data_filename = kUseLDPC ? x : y;
Avoid magic numbers. Instead of:
n_rows = (ldpc_config.bg == 1) ? 46 : 42;
prefer:
n_rows = (ldpc_config.bg == 1) ? kBg1RowTotal : kBg2RowTotal;
size_t fft_thread_num = cfg->fft_thread_num;
, prefer using cfg->fft_thread_num
directly.Use enum classes instead of enums or macros. So instead of:
#define PRINT_RX_PILOTS 0 #define PRINT_RX 1
prefer:
enum class PrintType {kRXPilots, kRX};
kVerbose
).size_t
as the integer type unless negative integers are needed.const
.static_cast
and reinterpret_cast
instead of C-style casts.Use auto type deduction when the type is clear. So instead of:
struct Packet *pkt = new struct Packet[kNumPackets];
prefer:
auto *pkt = new Packet[kNumPackets];
#