CPP style guide


#1

Premise: I am new to cpp

I find very annoying to have to manually lint the code everytime I push something…
I am myself using eclipse oxygen to write and build the code.
First of all, the generateEclipseProject makes the project compatible with Eclipse but there’s a settings to make the preprocessor like the code.
In eclipse neon i had to set cross gcc compiler in the preprocessor option.
In eclipse Oxygen this option is not visible anymore under project/preferences.
The only way was to install the old neon version, set this option then migrate the workspace to oxygen.
Is there any faster way to do that directly with a fresh install of oxygen? (neon is not anymore compatible with high sierra)

Then, a cpp lint plugin is available in eclipse:
CppStyle
It only needs one file inside the licode/erizo folder called CPPLINT.cfg with the following content to match our runner lint style:
set noparent
filter=-legal/copyright
filter=-build/include
linelength=120

Finally there’s a powerfool tool called clang-format (which can be found in brew (osx) or apt-get (ubuntu)), that automatically format the code based on a preconfigured style option once the file is being saved.

This will make the code way more readable and organized (the includes are also ordered by alphabetic order!!)
Maybe we can follow the webrtc google style guide:
clang-format (webrtc)

this guy also made a script to format recursively a project in one click:
clang-format-all

If we choose a standard and put the .clang-format in the erizo dir, everything will be much easier.

What do you think?
I think that the c++ part of the project need an update readme to help people setup in eclipse a fully working environment from scratch with all these suggestions.
Will speed up the contributing project.

Let me know @Javier


#2

Friendly bump to this post (i have to write at least 20 chars)