Difference between revisions of "RidgeRun Developer Manual/Coding Styles/C++"
Line 25: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | A derived good practice is to use <code>const</code> keyword as much as you can: | ||
+ | <syntaxhighlight lang="c++"> | ||
+ | const int val = 1; | ||
+ | if (val = 2) { // This should not compile | ||
+ | ... | ||
+ | } | ||
+ | </syntaxhighlight> | ||
Revision as of 17:34, 21 October 2020
WORK IN PROGRESS. Please Contact RidgeRun OR email to support@ridgerun.com if you have any questions. |
RidgeRun Developer Manual |
---|
![]() |
Coding Styles |
Development Tools |
Editors |
Debugging Tools |
Methodologies |
Design Patterns |
Testing |
Build Systems |
Contact Us |
Introduction to 'C++' Coding Styles
There are many coding styles as the concept covers a lot of aspects when writing software source code. In general RidgeRun tries to follow the Google C++ Style Guide.
Other good practices
Conditionals
- Keep the constants at the left side of a comparison. This applies to all C++ comparison operators. For example:
if ( NULL == var ) {
// ...
}
This is to avoid possible bugs like:
if ( var = NULL ) {
// ...
}
A derived good practice is to use const
keyword as much as you can:
const int val = 1;
if (val = 2) { // This should not compile
...
}