OpenTitus Wiki

Coding Style (Basic)

12pages on
this wiki
Add New Page
Comments0 Share

Rule 1: all H Files will be guarded by a guardian:

 #ifndef __MYFILE_H_
 #define __MYFILE_H_

Rule 2:

H files will never produce code, neither declare new variables.

Global variables will reside in a C file and externed in the H.

 uint32 gMyGlobalVariable;      // forbidden!
 uint32 MyFunction()           
 {                              // forbidden!
 #define MY_MACRO(a) printf(a) // OK.
 uint32 MyPrototype()          // OK.

Rule 3:

Please follow the following structure:

 if (condition)  // one space after the if.
 else            // optional.

Rule 4:

Function's Failure and single-exit point. This is the only permitted form of goto.

 bool MyFraction(uint8 a, uint8 b, uint32* out)
     bool Result = false;
     if ( 0 == b )
     {    // Division by zero!
          goto Failure;
     Result = true;
     return Result;

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.