<li>One line comment: (never in #define xxx ==> too dangerous) <divclass="fragment"><divclass="line"><spanclass="comment">//</span></div></div><!-- fragment --></li>
<li>Multiple line comment <divclass="fragment"><divclass="line"><spanclass="comment">/*</span></div><divclass="line"><spanclass="comment"> * xxxx yyyy</span></div><divclass="line"><spanclass="comment"> * zzzz</span></div><divclass="line"><spanclass="comment"> */</span></div></div><!-- fragment --></li>
<li>Documentation : doxygen (do not set un-nneded field)</li>
</ul>
<preclass="fragment">/**
* @brief my summery
* @param[in,out] _xxxx Comment on the variable
* @return my return explanation
*/
</pre><ul>
<li>one line documlentation: <divclass="fragment"><divclass="line">xxxxx, <spanclass="comment">//!< my comment</span></div></div><!-- fragment --></li>
<p>Tab size is a personal choice then, when you write code, you might be tab proof. If someone want to have the golden number for theire tabs, he will be able to do it. When you set a brace '{' you need to add a brace, and when you set a stop brace '}' you need to remove a tab To be simple : (tab stop at the 'if' start)</p>
<li>switch: <divclass="fragment"><divclass="line"><spanclass="keywordflow">switch</span> (suffix) {</div><divclass="line"><spanclass="keywordflow">case</span><spanclass="charliteral">'G'</span>:</div><divclass="line"><spanclass="keywordflow">case</span><spanclass="charliteral">'g'</span>:</div><divclass="line"> mem <<= 30;</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line"><spanclass="keywordflow">case</span><spanclass="charliteral">'M'</span>:</div><divclass="line"><spanclass="keywordflow">case</span><spanclass="charliteral">'m'</span>:</div><divclass="line"> mem <<= 20;</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line"><spanclass="keywordflow">case</span><spanclass="charliteral">'K'</span>:</div><divclass="line"><spanclass="keywordflow">case</span><spanclass="charliteral">'k'</span>:</div><divclass="line"> mem <<= 10;</div><divclass="line"><spanclass="comment">// fall through</span></div><divclass="line"><spanclass="keywordflow">default</span>:</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line">}</div></div><!-- fragment --></li>
<li>function: <divclass="fragment"><divclass="line"><spanclass="keywordtype">void</span> myFunction(<spanclass="keywordtype">void</span>) {</div><divclass="line"> actions ...;</div><divclass="line">}</div></div><!-- fragment --></li>
<li>classes: <divclass="fragment"><divclass="line"><spanclass="keyword">class </span>MyClass {</div><divclass="line"><spanclass="keyword">public</span>:</div><divclass="line"> MyClass(<spanclass="keywordtype">void</span>);</div><divclass="line"> ~MyClass(<spanclass="keywordtype">void</span>);</div><divclass="line"><spanclass="keyword">private</span>:</div><divclass="line"><spanclass="keyword">const</span><spanclass="keywordtype">char</span>* <aclass="codeRef"doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/"href="http://atria-soft.github.io/etk/_f_s_node_8hpp.html#adb042eb3c3641fb2d10af30b4be2e68b">getName</a>(<spanclass="keywordtype">void</span>);</div><divclass="line">};</div></div><!-- fragment --></li>
<li>namespace: <divclass="fragment"><divclass="line"><spanclass="keyword">namespace </span>appl {</div><divclass="line"><spanclass="keywordtype">void</span><spanclass="keyword">get</span>(void);</div><divclass="line">}</div></div><!-- fragment --></li>
<li>For special element like : you might add a tabulation too <divclass="fragment"><divclass="line"><spanclass="keywordflow">case</span> xxx:</div><divclass="line"> actions...</div><divclass="line">public:</div><divclass="line"> definition ...</div></div><!-- fragment --></li>
<li>An exception for the inline function inside c++ header: <divclass="fragment"><divclass="line"><spanclass="keyword">class </span>Plop {</div><divclass="line"><spanclass="keyword">private</span>:</div><divclass="line"> int32_t m_value; </div><divclass="line"><spanclass="keyword">public</span>:</div><divclass="line"> int32_t getValue(<spanclass="keywordtype">void</span>)<spanclass="keyword"> const </span>{ <spanclass="keywordflow">return</span> m_value; };</div></div><!-- fragment --></li>
<p>the element 'typedef' must not be use, like this it is not needed to add special element like '_te' or '_ts' to say respectively 'tpedef enum' and 'typedef struct' Structure is not availlable in c++, just use normal class, this is the same.</p>
<p>The star will be near the type : </p><divclass="fragment"><divclass="line"><spanclass="keywordtype">void</span>* myVariableName;</div></div><!-- fragment --><h1><aclass="anchor"id="ewol_coding_style_c_and_cpp"></a>
C and c++ </h1>
<p>All C header files might have : </p><divclass="fragment"><divclass="line"><spanclass="preprocessor">#ifdef __cplusplus</span></div><divclass="line"><spanclass="keyword">extern</span><spanclass="stringliteral">"C"</span> {</div><divclass="line"><spanclass="preprocessor">#endif</span></div><divclass="line"></div><divclass="line">...</div><divclass="line"></div><divclass="line">#ifdef __cplusplus</div><divclass="line"> }</div><divclass="line"><spanclass="preprocessor">#endif</span></div></div><!-- fragment --><h1><aclass="anchor"id="ewol_coding_style_naming"></a>
Naming </h1>
<ul>
<li>Fonction/Methods: Camel case with first letter in lower case. <divclass="fragment"><divclass="line"><spanclass="keywordtype">void</span> myExampleFontionName(<spanclass="keywordtype">void</span>);</div></div><!-- fragment --></li>
<li>Variable: Camel case with first letter in lower case. <divclass="fragment"><divclass="line">nt32_t myVariableExample;</div></div><!-- fragment --></li>
<li>namespace: one world in lower case <divclass="fragment"><divclass="line">namspace <aclass="code"href="namespaceewol.html">ewol</a> {</div></div><!-- fragment --></li>
<li>Class: Camel case with first letter in upper case. <divclass="fragment"><divclass="line"><spanclass="keyword">class </span>MyClass;</div></div><!-- fragment --></li>
<li>Members fields: Put a 'm' prefix and then a normal Variable name <divclass="fragment"><divclass="line">int32_t m_memberField;</div></div><!-- fragment --></li>
<li>enum: Camel case with first letter in lower case. <divclass="fragment"><divclass="line"><spanclass="keyword">enum</span> myEnum {</div><divclass="line"> myEnum_def1,</div><divclass="line"> myEnum_def2,</div><divclass="line"> myEnum_def3,</div><divclass="line">};</div></div><!-- fragment --></li>
<li>structure (C only) use naming like Classes (and for mamber too)</li>
<li>minimum size : Do not use variable with size <3, the for a iterator for a 'for' : <divclass="fragment"><divclass="line"><spanclass="keywordflow">for</span> (int32_t iii=0; iii<xxx; ++iii) {</div><divclass="line"><spanclass="comment">// actions ...</span></div><divclass="line">}</div></div><!-- fragment --></li>
<p>Une stanndard Type : </p><divclass="fragment"><divclass="line"><spanclass="keywordtype">bool</span></div><divclass="line">int8_t / uint8_t</div><divclass="line">int16_t / uint16_t</div><divclass="line">int32_t / uint32_t</div><divclass="line">int64_t / uint64_t</div><divclass="line"><spanclass="keywordtype">size_t</span></div><divclass="line">int (some <spanclass="keywordflow">case</span> needed)</div><divclass="line"><spanclass="keywordtype">float</span> / <spanclass="keywordtype">double</span></div><divclass="line"><aclass="codeRef"doxygen="/home/heero/dev/perso/out/doc/release/etk.tag:http://atria-soft.github.io/etk/"href="http://atria-soft.github.io/etk/types_8hpp.html#aef34e23d4cca9aba8d78eeb0ae8fcd2e">float_t</a> to automatic match whith the compilation choice between <spanclass="keywordtype">float</span> or <spanclass="keywordtype">double</span></div></div><!-- fragment --><h1><aclass="anchor"id="ewol_coding_style_specific"></a>
C++ specificity </h1>
<ul>
<li>STL You can use the Stl, but the porting and the result can be different depending on the board you are.</li>
<li>Heritage: Simple Heritage is a good use of the C++, multiple heritage is not really supported in every compilators.</li>
<li>const: Set the parameter and fonction const all time you can.</li>
<li>exception: They are not manage in all platforms, then by restriction, do not use it. </li>