Jump to content

RidgeRun Developer Manual/Coding Styles/C++: Difference between revisions

Line 12: Line 12:


In general, if you are adding code to an existent code, be consistent with the coding standard already being used. If no standard is used then follow this guide.
In general, if you are adding code to an existent code, be consistent with the coding standard already being used. If no standard is used then follow this guide.
=== FIle names ===
Filenames should be all lowercase and can include underscores (_) or dashes (-). Follow the convention that your project uses. If there is no consistent local pattern to follow, prefer "_".
<syntaxhighlight lang="c++">
my_useful_class.cc
my-useful-class.cc
</syntaxhighlight>


=== Comments ===
=== Comments ===
Line 70: Line 60:
One single empty line is fine to separate logical blocks. Avoid multiple empty lines, commented empty lines, etc.
One single empty line is fine to separate logical blocks. Avoid multiple empty lines, commented empty lines, etc.


== Naming ==
=== File names ===
Filenames should be all lowercase and can include underscores (_) or dashes (-). Follow the convention that your project uses. If there is no consistent local pattern to follow, prefer "_".
<syntaxhighlight lang="c++">
my_useful_class.cc
my-useful-class.cc
</syntaxhighlight>
=== Variable naming standard ===
=== Variable naming standard ===


Line 117: Line 118:
</syntaxhighlight>
</syntaxhighlight>


=== Conditionals ===
== Conditionals ==


*Keep the constants at the left side of a comparisons. This applies to all [https://en.cppreference.com/w/cpp/language/operator_comparison C++ comparison operators]. For example:
*Keep the constants at the left side of a comparisons. This applies to all [https://en.cppreference.com/w/cpp/language/operator_comparison C++ comparison operators]. For example:
Cookies help us deliver our services. By using our services, you agree to our use of cookies.