从返回码到 Result
C 开发者很熟悉这种错误处理方式:
int read_config(const char *path, struct Config *out);
函数返回 0 表示成功,非 0 表示失败;真正的结果通过输出参数写回。系统调用还会用 -1 加 errno。资源多一点时,再配合 goto cleanup 收尾。
C 开发者很熟悉这种错误处理方式:
int read_config(const char *path, struct Config *out);
函数返回 0 表示成功,非 0 表示失败;真正的结果通过输出参数写回。系统调用还会用 -1 加 errno。资源多一点时,再配合 goto cleanup 收尾。