Update style guide for C++.
Change-Id: Ib8c681e221837407d7ae2578699b8a3f3227c1b7 Reviewed-on: https://boringssl-review.googlesource.com/19785 Commit-Queue: Steven Valdez <svaldez@google.com> Reviewed-by: Steven Valdez <svaldez@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
parent
c11ea942b7
commit
3536809644
19
STYLE.md
19
STYLE.md
@ -31,10 +31,10 @@ Variable declarations in the middle of a function or inside a `for` loop are
|
|||||||
allowed and preferred where possible. Note that the common `goto err` cleanup
|
allowed and preferred where possible. Note that the common `goto err` cleanup
|
||||||
pattern requires lifting some variable declarations.
|
pattern requires lifting some variable declarations.
|
||||||
|
|
||||||
Comments should be `/* C-style */` for consistency.
|
Comments should be `// C99-style` for consistency with C++.
|
||||||
|
|
||||||
When declaration pointer types, `*` should be placed next to the variable
|
When declaring pointer types, `*` should be placed next to the variable name,
|
||||||
name, not the type. So
|
not the type. So
|
||||||
|
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
|
|
||||||
@ -60,6 +60,19 @@ constants for flags. If adding values to an existing set of `#define`s,
|
|||||||
continue with `#define`.
|
continue with `#define`.
|
||||||
|
|
||||||
|
|
||||||
|
## libssl
|
||||||
|
|
||||||
|
libssl was originally written in C but is being incrementally rewritten in
|
||||||
|
C++11. As of writing, much of the style matches our C conventions rather than
|
||||||
|
Google C++. Additionally, libssl on Linux currently may not depend on the C++
|
||||||
|
runtime. See the C++ utilities in `ssl/internal.h` for replacements for
|
||||||
|
problematic C++ constructs. The `util/check_imported_libraries.go` script may be
|
||||||
|
used with a shared library build to check if a new construct is okay.
|
||||||
|
|
||||||
|
If unsure, match surrounding code. Discrepancies between it and Google C++ style
|
||||||
|
will be fixed over time.
|
||||||
|
|
||||||
|
|
||||||
## Formatting
|
## Formatting
|
||||||
|
|
||||||
Single-statement blocks are not allowed. All conditions and loops must
|
Single-statement blocks are not allowed. All conditions and loops must
|
||||||
|
@ -221,7 +221,7 @@ UniquePtr<T> MakeUnique(Args &&... args) {
|
|||||||
#define HAS_VIRTUAL_DESTRUCTOR
|
#define HAS_VIRTUAL_DESTRUCTOR
|
||||||
#define PURE_VIRTUAL = 0
|
#define PURE_VIRTUAL = 0
|
||||||
#else
|
#else
|
||||||
// HAS_VIRTUAL_DESTRUCTOR should be declared in any base clas ~s which defines a
|
// HAS_VIRTUAL_DESTRUCTOR should be declared in any base class which defines a
|
||||||
// virtual destructor. This avoids a dependency on |_ZdlPv| and prevents the
|
// virtual destructor. This avoids a dependency on |_ZdlPv| and prevents the
|
||||||
// class from being used with |delete|.
|
// class from being used with |delete|.
|
||||||
#define HAS_VIRTUAL_DESTRUCTOR \
|
#define HAS_VIRTUAL_DESTRUCTOR \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user