<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de-AT">
	<id>https://becomwiki.live.md-websolutions.com/index.php?action=history&amp;feed=atom&amp;title=BLACKSheep%C2%AE_Coding_Guideline</id>
	<title>BLACKSheep® Coding Guideline - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://becomwiki.live.md-websolutions.com/index.php?action=history&amp;feed=atom&amp;title=BLACKSheep%C2%AE_Coding_Guideline"/>
	<link rel="alternate" type="text/html" href="https://becomwiki.live.md-websolutions.com/index.php?title=BLACKSheep%C2%AE_Coding_Guideline&amp;action=history"/>
	<updated>2026-05-13T13:29:05Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in BECOM Systems Support</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://becomwiki.live.md-websolutions.com/index.php?title=BLACKSheep%C2%AE_Coding_Guideline&amp;diff=224&amp;oldid=prev</id>
		<title>Peter: 1 Version importiert</title>
		<link rel="alternate" type="text/html" href="https://becomwiki.live.md-websolutions.com/index.php?title=BLACKSheep%C2%AE_Coding_Guideline&amp;diff=224&amp;oldid=prev"/>
		<updated>2023-10-31T08:03:08Z</updated>

		<summary type="html">&lt;p&gt;1 Version importiert&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de-AT&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 31. Oktober 2023, 10:03 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;de-AT&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(kein Unterschied)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Peter</name></author>
	</entry>
	<entry>
		<id>https://becomwiki.live.md-websolutions.com/index.php?title=BLACKSheep%C2%AE_Coding_Guideline&amp;diff=223&amp;oldid=prev</id>
		<title>en&gt;Peter: 1 Version importiert</title>
		<link rel="alternate" type="text/html" href="https://becomwiki.live.md-websolutions.com/index.php?title=BLACKSheep%C2%AE_Coding_Guideline&amp;diff=223&amp;oldid=prev"/>
		<updated>2023-08-22T19:35:50Z</updated>

		<summary type="html">&lt;p&gt;1 Version importiert&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Scope ==&lt;br /&gt;
[[File:Blacksheep320x240.jpg|right]]This page contains naming, structure and design rules for writing &amp;lt;code&amp;gt;C code&amp;lt;/code&amp;gt; at BLACKSheep® OS for Blackfin® processors.&lt;br /&gt;
&lt;br /&gt;
== Naming of identifiers ==&lt;br /&gt;
Every identifier has to be named in English.&lt;br /&gt;
&lt;br /&gt;
The first character of an identifier must not contain underscores (there are some compiler directives which start with underscores and this could lead to conflicts)!&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
* Mixed case letters has to be used and the appropriate prefixes have to be inserted where necessary.&lt;br /&gt;
* Variable names have to be self explanatory. The names have to be provided with the appropriate prefixes and they have to start with an uppercase letter.&amp;lt;br/&amp;gt; In case of combining prefixes, the use of ranges/arrays/pointer/enumerations/structures is at first, followed by basic data types or object prefixes.&lt;br /&gt;
* The only exception are loop variables (thereby the use of i, j, k is allowed).&lt;br /&gt;
* Only one variable declaration per line is allowed&lt;br /&gt;
* Pointer operators at the declaration have to be located in front of the variable (not after the type identifier).&lt;br /&gt;
* If possible Initializations have to be done directly at the declaration.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
;Prefixes for ranges/arrays/pointer/enumerations/structures&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix!! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;g_&amp;lt;/code&amp;gt;   || For global varaibles.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;s_&amp;lt;/code&amp;gt;   || For static variables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;pa_&amp;lt;/code&amp;gt; || For function parameters.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;    || For arrays.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;   || For function pointers.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;   || For pointers.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;   || For self definend datatypes e.g. enumerations, structures.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;h&amp;lt;/code&amp;gt;   || For handlers.&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
;Prefixes for basic data types&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix!! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;   || For characters (8Bit).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;   || For boolean (1Bit).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; || For datatype: int (32Bit) and long (32Bit).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt;    || For all kind of floating point datatypes.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;s&amp;lt;/code&amp;gt;   || For short(16Bit).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ll&amp;lt;/code&amp;gt;   || For long long (64Bit).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt;   || Additional prefix to indicate an unsigned variable.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
; Prefixes for basic global variables&lt;br /&gt;
For global variables the prefix &amp;lt;code&amp;gt;g_&amp;lt;/code&amp;gt; should be used, followed by the type prefix.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 bool  g_bIsInitialized;&lt;br /&gt;
 void aFunction (int pa_nParameter) {&lt;br /&gt;
   int nNumber;&lt;br /&gt;
   int *pnNumber = &amp;amp;nNumber;&lt;br /&gt;
   char cKey;&lt;br /&gt;
   float fPi = 3.1415;&lt;br /&gt;
   int anNumbers[10];&lt;br /&gt;
   unsigned char * pucPac;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
Defining your own datatypes is common and necessary to improve code readability.&amp;lt;br/&amp;gt;&lt;br /&gt;
The notation for self defined datatypes is: &amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;T_TYPE_DESCRIPTION&amp;lt;/source&amp;gt;&lt;br /&gt;
; Example&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 typedef unsigned long T_UART_HANDLE;&lt;br /&gt;
&lt;br /&gt;
 typedef struct _EXAMPLE_CFG {&lt;br /&gt;
    bool           bDTParalell;&lt;br /&gt;
    unsigned long  unIVG;&lt;br /&gt;
    unsigned long  unPPIerrIVG;&lt;br /&gt;
    unsigned long  unDMAerrIVG;&lt;br /&gt;
 } T_EXAMPLE_CFG;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Blocks ===&lt;br /&gt;
The left parenthesis of a block has to be in the same line as the starting construct. &amp;lt;br/&amp;gt;&lt;br /&gt;
The right parenthesis has to be in an own line.&lt;br /&gt;
The parenthesis must &amp;#039;&amp;#039;&amp;#039;ALWAYS&amp;#039;&amp;#039;&amp;#039; be used! Also in single &amp;#039;&amp;#039;for&amp;#039;&amp;#039; or &amp;#039;&amp;#039;if&amp;#039;&amp;#039; statements!&lt;br /&gt;
; &amp;#039;&amp;#039;Never&amp;#039;&amp;#039; type something like this&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 if (x == 1) y = 10;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
or this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 if (x==1)&lt;br /&gt;
   y=10;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== BLACKSheep® conform notation ====&lt;br /&gt;
; if /else statements&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 if (...) {&lt;br /&gt;
   ...&lt;br /&gt;
 } else if (...) {&lt;br /&gt;
   ...&lt;br /&gt;
 } else {&lt;br /&gt;
   ...&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; For statements&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 for (...) {&lt;br /&gt;
   ...&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Switch/case statements&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 switch (nVariable) {&lt;br /&gt;
   case 0 : {&lt;br /&gt;
              ...&lt;br /&gt;
              break;&lt;br /&gt;
   }&lt;br /&gt;
   case 1 : {&lt;br /&gt;
              ...&lt;br /&gt;
              break;&lt;br /&gt;
   }&lt;br /&gt;
   default : {&lt;br /&gt;
              ...&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
Functions should start with a three or four letter identifier common for all functions in a c-file. &amp;lt;br/&amp;gt;&lt;br /&gt;
The letters should be in upper case.&lt;br /&gt;
&lt;br /&gt;
The left parenthesis of the function has to be in the same line as the last parameter and the close bracket.&lt;br /&gt;
; Example&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 T_ERROR_CODE UARTwriteByte(T_UART_HANDLE pa_tHndl, unsigned char pa_ucValue) {&lt;br /&gt;
     ...&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If the number of parameters is too long to fit in one line the function declaration should be formatted as follow:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 T_ERROR_CODE UARTsetMode ( unsigned long pa_unBaudrate,&lt;br /&gt;
                            unsigned char pa_ucStopBits,&lt;br /&gt;
                            unsigned char pa_ucParity ) {&lt;br /&gt;
     ...&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Error codes ===&lt;br /&gt;
If the function returns an error code the T_ERROR_CODE declaration should be used (declared in “&amp;#039;&amp;#039;&amp;#039;driver/include/datatypes.h&amp;#039;&amp;#039;&amp;#039;”). &amp;lt;br/&amp;gt;&lt;br /&gt;
A generic error type called ERR_GENERIC is already defined there.&lt;br /&gt;
The “driver/include” path must be added to the project options as a standard include path.&lt;br /&gt;
All error values should be derived from ERR_GENERIC.&lt;br /&gt;
; Example&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;lt;datatypes.h&amp;gt;&lt;br /&gt;
 #define UART_ERR_RX_BUFFER_FULL    (ERR_GENERIC – 10)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Include guards ===&lt;br /&gt;
The use of include guards is recommended. If used, they have to look like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #ifndef _SAMPLE_H_INCLUDED_&lt;br /&gt;
 #define _SAMPLE_H_INCLUDED_&lt;br /&gt;
 ...&lt;br /&gt;
 #endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Include paths ===&lt;br /&gt;
Include paths has to be relative. &amp;#039;&amp;#039;&amp;#039;Don’t use absolute paths&amp;#039;&amp;#039;&amp;#039;!&amp;lt;br/&amp;gt;&lt;br /&gt;
Use slashes as directory separator. &amp;#039;&amp;#039;&amp;#039;Don’t use backslash&amp;#039;&amp;#039;&amp;#039;!&lt;br /&gt;
; Example&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #include “../vdm/vdmconfig.h”&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Include files from standard include directories (VDSP++ as well as BLACKSheep) has to be declared as follow:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Standard include directories for BLACKSheep are:&lt;br /&gt;
* Driver/ include&lt;br /&gt;
* Blacksheep/include&lt;br /&gt;
Both directories should be added as standard include directories on all VDSP++ projects.&lt;br /&gt;
&lt;br /&gt;
=== Macros ===&lt;br /&gt;
&lt;br /&gt;
Macro should be in &amp;#039;&amp;#039;&amp;#039;capital letters&amp;#039;&amp;#039;&amp;#039; and&amp;#039;&amp;#039;&amp;#039; self explaining.&amp;#039;&amp;#039;&amp;#039; &amp;lt;br/&amp;gt;&lt;br /&gt;
Macros should start with a three or four byte identifier related to the c-file or the function block. &amp;lt;br/&amp;gt;&lt;br /&gt;
As separator use the underline character.&lt;br /&gt;
; Example&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #define UART_PARITY_NONE                0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Indentation ===&lt;br /&gt;
The tabulator width has to be set to four. &amp;lt;br/&amp;gt;&amp;#039;&amp;#039;&amp;#039;Instead&amp;#039;&amp;#039;&amp;#039; of tabulator &amp;#039;&amp;#039;characters spaces&amp;#039;&amp;#039; have to be inserted (usually there is an option for this in the IDE). &amp;lt;br/&amp;gt;&lt;br /&gt;
In VDSP++:  {{mp|Settings|Prefernces|Editor Tab}}.&amp;lt;br/&amp;gt;&lt;br /&gt;
A new block has to be started at the same line as its initial statement.&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
A sufficient amount of comments have to be written. &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;There are never too many comments, whereas invalid comments are worse than none&amp;#039;&amp;#039;&amp;#039; – thus &amp;#039;&amp;#039;&amp;#039;invalid comments&amp;#039;&amp;#039;&amp;#039; have to be removed from the source code. &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comments have to be written in English. It is allowed to indicate Single-line comments with // ahead of the command or in the same line right after the command. All other comments have to be located ahead of the command or block.&lt;br /&gt;
&lt;br /&gt;
Generally comments have to be tagged with &amp;#039;&amp;#039;&amp;#039;//&amp;#039;&amp;#039;&amp;#039; or the doxygen style &amp;#039;&amp;#039;&amp;#039;///&amp;lt; not /*…*/ to allow the temporarily commenting out of code with /* … */!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Comments have to be meaningful, to describe to program and to be up to date.&lt;br /&gt;
&lt;br /&gt;
All c- and h-files in addition must have &amp;#039;&amp;#039;&amp;#039;doxygen compatible&amp;#039;&amp;#039;&amp;#039; comments as described [[BLACKSheep® Doxygen Guideline| here]].&lt;/div&gt;</summary>
		<author><name>en&gt;Peter</name></author>
	</entry>
</feed>