aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/c-style-guide.md
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2017-09-13 13:41:59 -0700
committerGravatar GitHub <noreply@github.com>2017-09-13 13:41:59 -0700
commit1217c4d0527e5b896f7720fcdbcd3f87ec4c1359 (patch)
tree10c076b7b3142a43f99e421e31876e0f0c56a16e /doc/c-style-guide.md
parent0087d25e6078681b97d8aa200db189f6a0256d7d (diff)
parent4a7fca5b655f5e9114c81f48b3615847c5cb783d (diff)
Merge pull request #12519 from vjpai/stylin
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`.