|
GRPC Core
50.0.0
|
Here we document style rules for C usage in the gRPC Core library.
All header files should have a #define guard to prevent multiple inclusion. To guarantee uniqueness they should be based on the file's path.
For public headers: include/grpc/grpc.h → GRPC_GRPC_H
For private headers: src/core/lib/channel/channel_stack.h → GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H
When declaring a (non-static) pointer variable, always initialize it to NULL. Even in the case of static pointer variables, it's recommended to explicitly initialize them to NULL.
Within public header files, only /* */ comments are allowed.
Within implementation files and private headers, either single line // or multi line /* */ comments are allowed. Only one comment style per file is allowed however (i.e. if single line comments are used anywhere within a file, ALL comments within that file must be single line comments).
grpc_grpc_structs , unions, and enums must be prefixed by grpc_ if they are declared in a header file. They must not be prefixed by grpc_ if they are declared in a source file.#define names must be uppercase. All other values must be lowercase.#define names defined in a header file must be prefixed with GRPC_ (except for #define macros that are being used to substitute functions; those should follow the general rules for functions). Enumeration values or #defines defined in source files must not be prefixed with GRPC_.variable_name.atexit() is in forbidden in libgrpc.
1.8.17