aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/c-style-guide.md
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2017-09-12 14:31:11 -0700
committerGravatar Vijay Pai <vpai@google.com>2017-09-13 10:39:28 -0700
commit4a7fca5b655f5e9114c81f48b3615847c5cb783d (patch)
treecb3756f7fceb06b4fa9d5aa721ba0774afd1ffc4 /doc/c-style-guide.md
parentce286cb3a8946ff85d760d3988a75a5fcafe1b60 (diff)
Give guidance on prefixing struct/enum/#define names
Diffstat (limited to 'doc/c-style-guide.md')
-rw-r--r--doc/c-style-guide.md14
1 files changed, 11 insertions, 3 deletions
diff --git a/doc/c-style-guide.md b/doc/c-style-guide.md
index 369bd56a46..2cfa41dd9e 100644
--- a/doc/c-style-guide.md
+++ b/doc/c-style-guide.md
@@ -32,14 +32,14 @@ Header Files
# endif
```
- Header files should be self-contained and end in .h.
-- All header files should have a #define guard to prevent multiple inclusion.
+- 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/channel/channel_stack.h` →
- `GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H`
+ `src/core/lib/channel/channel_stack.h` →
+ `GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H`
Variable Initialization
-----------------------
@@ -72,8 +72,16 @@ Symbol Names
- Non-static functions must be prefixed by `grpc_`
- Static functions must *not* be prefixed by `grpc_`
+- Typenames of `struct`s , `union`s, and `enum`s 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.
- Enumeration values and `#define` names must be uppercase. All other values
must be lowercase.
+- Enumeration values or `#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 `#define`s defined in source files must not
+ be prefixed with `GRPC_`.
- Multiple word identifiers use underscore as a delimiter, *never* camel
case. E.g. `variable_name`.