diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9659ebe887..b6883e0bf5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont ## Coding Guidelines -WPILib uses Google style guides for both C++ and Java. Autoformatters are available for many popular editors at [https://github.com/google/styleguide]. An online version of the styleguide for [C++](https://google.github.io/styleguide/cppguide.html) and [Java](https://google.github.io/styleguide/javaguide.html) are also available. Additionally, offline copies of the style guide can be found in the style guide directory of the repository. +WPILib uses modified Google style guides for both C++ and Java, which can be found in the style guide directory of the repository. Autoformatters are available for many popular editors at https://github.com/google/styleguide. Another option for C++ is running format.py in the style guide directory. While the library should be fully formatted according to the styles, additional elements of the style guide were not followed when the library was initially created. All new code should follow the guidelines. If you are looking for some easy ramp-up tasks, finding areas that don't follow the style guide and fixing them is very welcome. diff --git a/README.md b/README.md index 1c4cb75855..6d0283813f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/wpilibsuite/allwpilib.svg?branch=master)](https://travis-ci.org/wpilibsuite/allwpilib) -Welcome to the WPILib project. This repository contains the HAL, WPILibJ, and WPILibC projcts. These are the core libraries for creating robot programs for the roboRIO. +Welcome to the WPILib project. This repository contains the HAL, WPILibJ, and WPILibC projects. These are the core libraries for creating robot programs for the roboRIO. - [WPILib Mission](#wpilib-mission) - [Building WPILib](#building-wpilib) diff --git a/styleguide/cppguide.html b/styleguide/cppguide.html index 768de1a635..4d80a13596 100644 --- a/styleguide/cppguide.html +++ b/styleguide/cppguide.html @@ -198,7 +198,7 @@ are meant for textual inclusion, but are not headers, should end in

All header files should be self-contained. In other words, users and refactoring tools should not have to adhere to special conditions in order to include the header. Specifically, a -header should have header guards, +header should have #pragma once, should include all other headers it needs, and should not require any particular symbols to be defined.

@@ -222,36 +222,11 @@ instantiates the template.

-

The #define Guard

+

#pragma once

-

All header files should have #define guards to -prevent multiple inclusion. The format of the symbol name -should be -<PROJECT>_<PATH>_<FILE>_H_.

-
- -
- - - -

To guarantee uniqueness, they should -be based on the full path in a project's source tree. For -example, the file foo/src/bar/baz.h in -project foo should have the following -guard:

- -
#ifndef FOO_BAR_BAZ_H_
-#define FOO_BAR_BAZ_H_
-
-...
-
-#endif  // FOO_BAR_BAZ_H_
-
- - - - +

All header files should have #pragma once at the top to +prevent multiple inclusion.

Forward Declarations

@@ -818,18 +793,13 @@ discussion of namespaces and how to name them.

Enumerator Names

-

Enumerators should be named either like -constants or like -macros: either kEnumName or -ENUM_NAME.

+

Enumerators should be named like +constants: kEnumName.

-

Preferably, the individual enumerators should be named -like constants. However, it -is also acceptable to name them like -macros. The enumeration name, +

The enumeration name, UrlTableErrors (and AlternateUrlTableErrors), is a type, and therefore mixed case.

@@ -839,24 +809,8 @@ therefore mixed case.

kErrorOutOfMemory, kErrorMalformedInput, }; -enum AlternateUrlTableErrors { - OK = 0, - OUT_OF_MEMORY = 1, - MALFORMED_INPUT = 2, -}; -

Until January 2009, the style was to name enum values -like macros. This caused -problems with name collisions between enum values and -macros. Hence, the change to prefer constant-style naming -was put in place. New code should prefer constant-style -naming if possible. However, there is no reason to change -old code to use constant-style names, unless the old -names are actually causing a compile-time problem.

- - -

Macro Names

@@ -1390,10 +1344,9 @@ everyone's code easily.

-

To help you format code correctly, we've -created a - -settings file for emacs.

+

To help your code conform to our format, we've +created a python script that runs clang-format on it +and performs various other checks.

Line Length

@@ -1443,10 +1396,6 @@ should appear near top of a file.

An #include statement with a long path may exceed 80 columns.

- -

You needn't be concerned about -header guards that exceed -the maximum length.