C++ Style Guide

Hi,

it is time to write a C++ Coding Style Guide for RIOT. Since C and C++ have different traditions here, I will simply start to suggest using the C++ Style used in CAF [1]. While it is not identical, the style is relates to the guidelines used by Google and C++ Standard Library.

Raphael

[1] https://github.com/actor-framework/actor-framework/blob/develop/CONTRIBUTING.md

Good initiative!

Could you create a new wiki article similar to https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions for the C++ conventions?

/Joakim

Hi Raphael,

Hi Johann!

How I see it is very similar to RIOT coding style. 2 spaces per indentation level is not acceptable to me, should be 4 as in C coding style. Otherwise, I find it very good.

I agree to object a 2 spaces-indentation.

By the way, can someone explain to me short why we need C ++ at all?

Is this a metaphysical question? :wink:

SCNR: “There are only two things wrong with C++: The initial concept and the implementation.” (Bertrand Meyer)

Cheers, Oleg

Hi Raphael,

Hi,

it is time to write a C++ Coding Style Guide for RIOT. Since C and C++ have different traditions here, I will simply start to suggest using the C++ Style used in CAF [1]. While it is not identical, the style is relates to the guidelines used by Google and C++ Standard Library.

How I see it is very similar to RIOT coding style. 2 spaces per indentation level is not acceptable to me, should be 4 as in C coding style. Otherwise, I find it very good.

+1, indentation must match between the C and C++ coding conventions, there will be fewer style mistakes that way.

By the way, can someone explain to me short why we need C ++ at all?

I quite enjoy writing applications in C++ instead of C. The C++ support is basically just a service to other RIOT users like me who like to use C++ for writing their applications.

I don't know if the RIOT community will be open to having RIOT modules and device drivers written in C++, (other than the C++ support modules, of course).

Regards, Joakim

Hello,

I created a wiki article [1], which is not linked anywhere yet.

How I see it is very similar to RIOT coding style. 2 spaces per indentation level is not acceptable to me, should be 4 as in C coding style. Otherwise, I find it very good.

+1, indentation must match between the C and C++ coding conventions, there will be fewer style mistakes that way.

For the first revision I changed the indentation to 4 spaces and removed the CAF names. Hopefully I found all of them.

I quite enjoy writing applications in C++ instead of C. The C++ support is basically just a service to other RIOT users like me who like to use C++ for writing their applications.

+1

Raphael

[1] Create new page · RIOT-OS/RIOT Wiki · GitHub