Skip to content

Commit

Permalink
Update style guide for C++.
Browse files Browse the repository at this point in the history
Change-Id: Ib8c681e221837407d7ae2578699b8a3f3227c1b7
Reviewed-on: https://boringssl-review.googlesource.com/19785
Commit-Queue: Steven Valdez <[email protected]>
Reviewed-by: Steven Valdez <[email protected]>
CQ-Verified: CQ bot account: [email protected] <[email protected]>
  • Loading branch information
davidben authored and CQ bot account: [email protected] committed Aug 30, 2017
1 parent c11ea94 commit 3536809
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
name, not the type. So
When declaring pointer types, `*` should be placed next to the variable name,
not the type. So

uint8_t *ptr;

Expand All @@ -60,6 +60,19 @@ constants for flags. If adding values to an existing set of `#define`s,
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

Single-statement blocks are not allowed. All conditions and loops must
Expand Down
2 changes: 1 addition & 1 deletion ssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ UniquePtr<T> MakeUnique(Args &&... args) {
#define HAS_VIRTUAL_DESTRUCTOR
#define PURE_VIRTUAL = 0
#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
// class from being used with |delete|.
#define HAS_VIRTUAL_DESTRUCTOR \
Expand Down

0 comments on commit 3536809

Please sign in to comment.