Skip to content

Commit

Permalink
Don't global initialize anything to nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
vjpai committed Jun 16, 2016
1 parent b31a9a0 commit b8916aa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/cpp-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b8916aa

Please sign in to comment.