aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2016-06-16 09:16:00 -0700
committerGravatar vjpai <vpai@google.com>2016-06-16 09:16:00 -0700
commitb8916aa22fe1d2c1163986b834f5bd0543476573 (patch)
tree2569a516af0fe96197660964ab00738564a34309
parentb31a9a0900463fb29c6a3c9cbcfc038292eda6d5 (diff)
Don't global initialize anything to nullptr
-rw-r--r--doc/cpp-style-guide.md6
1 files changed, 6 insertions, 0 deletions
diff --git a/doc/cpp-style-guide.md b/doc/cpp-style-guide.md
index 9408c4abd6..0138ceb737 100644
--- a/doc/cpp-style-guide.md
+++ b/doc/cpp-style-guide.md
@@ -53,6 +53,12 @@ default capture). Other C++ functional features such as
(../include/grpc++/impl/codegen/config.h). Instead, pointers should
be checked for validity using their implicit conversion to `bool`.
In other words, use `if (p)` rather than `if (p != nullptr)`
+- Do not initialize global/static pointer variables to `nullptr`. Just let
+ the compiler implicitly initialize them to `nullptr` (which it will
+ definitely do). The reason is that `nullptr` is an actual object in
+ our implementation rather than just a constant pointer value, so
+ static/global constructors will be called in a potentially
+ undesirable sequence.
- Do not use `final` or `override` as these are not supported by some
compilers. Instead use `GRPC_FINAL` and `GRPC_OVERRIDE` . These
compile down to the traditional C++ forms for compilers that support