// 放在变量名之后,函数返回非 void
IpcRunLoop* Create(
void* obj,
IpcRunLoop* run_loop DAS_LIFETIMEBOUND = nullptr); // ✓
// 构造函数参数
explicit IpcRunLoop(IpcRunLoop& other DAS_LIFETIMEBOUND); // ✓
// 返回引用
IpcRunLoop& GetRunLoop(IpcRunLoop& obj DAS_LIFETIMEBOUND); // ✓// ✗ 函数返回 void 时不能使用
void SetRunLoop(IpcRunLoop& run_loop DAS_LIFETIMEBOUND);
// ✗ 放在变量名之前
void SetRunLoop(IpcRunLoop& DAS_LIFETIMEBOUND run_loop);- 只能用于返回非 void 类型的函数参数
- 必须放在变量名之后
- 构造函数参数可以使用
- 返回指针/引用的 getter 函数参数可以使用
每次编辑 C++ 文件(.cpp、.h、.hpp)后,必须调用 clang-format 格式化文件:
clang-format -i <文件路径>严禁使用单行 if 语句,必须使用花括号:
// ✗ 禁止
if (x) return;
if (x) doSomething();
// ✓ 正确
if (x) {
return;
}
if (x) {
doSomething();
}严禁在日志中使用 0x{:08X} 等十六进制格式记录 DasResult 错误码:
// ✗ 禁止
DAS_CORE_LOG_ERROR("Operation failed: result=0x{:08X}", result);
// ✓ 正确 - 直接记录数值
DAS_CORE_LOG_ERROR("Operation failed: result={}", result);原因:DasResult 错误码使用十进制数值定义,使用十六进制格式会导致日志难以阅读和调试。
必须在日志中使用 0x{:08X} 格式记录 interface_hash(FNV-1a hash of GUID):
// ✓ 正确
DAS_CORE_LOG_ERROR("interface_hash=0x{:08X}", interface_hash);
// ✗ 禁止
DAS_CORE_LOG_ERROR("interface_hash={}", interface_hash);原因:interface_hash 在代码中(IpcProxyFactory.h 等)以十六进制 case 值定义(如 0x84E3ADFC),使用十六进制格式才能快速定位对应的接口类型。