User Tools

Site Tools


coding_standards

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
coding_standards [2019/06/11 14:18]
hutch
coding_standards [2019/10/10 08:33] (current)
hutch
Line 37: Line 37:
   * All scalar constant values must be defined using #define and anything defined by a ''#​define''​ must use all uppercase letters in its name.    * All scalar constant values must be defined using #define and anything defined by a ''#​define''​ must use all uppercase letters in its name. 
   * Use the ''​const''​ key word only if you are defining an array of constant values, e.g., ''​const int foo[2] = {1, 2};''​   * Use the ''​const''​ key word only if you are defining an array of constant values, e.g., ''​const int foo[2] = {1, 2};''​
-  * The constants ''​0''​ and ''​1''​ can be used without a ''#​define''​ within if-expressions,​ and while- and for-loops, e.g., ''​for (int16_t i=0;​)'',​ ''​if (i==0)'',​ and ''​while (1)''​. You can use '​1'​ and '​0'​ to initialize variables. You can also use ''​0''​ and ''​1''​ in assignment or arithmetic expressions. No other exceptions are allowed. See the code below for examples of how to use '​1'​ and '​0'​.+  * The constants ''​0''​ and ''​1''​ can be used without a ''#​define''​ within if-expressions,​ and while- and for-loops, e.g., ''​for (int16_t i=0;​)'',​ ''​if (i==0)'',​ and ''​while (1)''​. You can use '​1'​ and '​0'​ to initialize variables. You can also use ''​0''​ and ''​1''​ in assignment or arithmetic expressions. No other exceptions are allowed.
   * You don't have to use your #define for strings ONLY if the string contains a printf formatting directive (%d, etc).   * You don't have to use your #define for strings ONLY if the string contains a printf formatting directive (%d, etc).
   * ''#​define''​ names should be meaningful, e.g., ''#​define TEN 10''​ may sound clever but you will lose points if you use ''#​define''​ this way.   * ''#​define''​ names should be meaningful, e.g., ''#​define TEN 10''​ may sound clever but you will lose points if you use ''#​define''​ this way.
coding_standards.txt ยท Last modified: 2019/10/10 08:33 by hutch