/
Style Standards

Style Standards

Spacing

Indentation

Always use spaces and not tabs.

  • In files autogenerated by CubeIDE, use 2 spaces (CubeIDE uses 2 spaces indent on any lines it writes)

  • In all other files use 4 spaces

When in doubt, follow the majority indent style in a file.

Braces

Keep braces on the same line as the opening statement (class, struct, function, enum, etc).

Do this:

statement { ... }

Do not do this:

statement { ... }

Add a single space between the statement and the opening brace.

Do this:

statement { ... }

Do not do this:

Operators

Add a space on either side of operators.

Do this:

Do not do this:

Comments

Add a space between '//' and the actual comment.

Do this:

Do not do this:

 


Naming

Variables

Type

Style

Example

Type

Style

Example

Members

Camel Case w/ Underscore

fooBar_

Constants

Screaming Snake Case

FOO_BAR

Defines

Screaming Snake Case

FOO_BAR

Others

Camel Case

fooBar

Data Structures

Type

Style

Example

Type

Style

Example

Classes

Pascal Case

FooBar

Structs

Pascal Case

FooBar

Enums

Pascal Case w/ Underscore 'e'

FooBar_e

Misc

Type

Style

Example

Type

Style

Example

Functions

Camel Case

fooBar

Typedefs

Pascal Case w/ Underscore 't'

FooBar_t

Files and Folders

Snake Case

foo_bar

Related content

Github Standards
Github Standards
Read with this
Code Guidelines
Code Guidelines
More like this
Coding Principles
Coding Principles
Read with this
Integrated Development Environments (IDEs)
Integrated Development Environments (IDEs)
More like this
Working with git
Working with git
Read with this
Schematic Styling
Schematic Styling
More like this