Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 902

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 902

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 876

Warning: Invalid argument supplied for foreach() in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 877

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 881

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 876

Warning: Invalid argument supplied for foreach() in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 877

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 881

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 902

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 902

Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 902
Difference between revisions of "SDCC coding style" - SDCC wiki

Difference between revisions of "SDCC coding style"


Warning: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in /home/project-web/sdcc/htdocs/mediawiki/includes/MagicWord.php on line 902
From SDCC wiki
Jump to: navigation, search
(Created page with "You can find many different coding styles in SDCC sources. <br> The preferred coding style is the one described in [http://www.gnu.org/prep/standards/standards.html GNU Coding...")
 
 
Line 1: Line 1:
You can find many different coding styles in SDCC sources. <br>
+
= SDCC C and C++ coding style =
 +
 
 +
You can find many different coding styles in SDCC sources.<br />
 
The preferred coding style is the one described in [http://www.gnu.org/prep/standards/standards.html GNU Coding Standards] document, [http://www.gnu.org/prep/standards/standards.html#Formatting 5.1 Formatting Your Source Code] chapter.
 
The preferred coding style is the one described in [http://www.gnu.org/prep/standards/standards.html GNU Coding Standards] document, [http://www.gnu.org/prep/standards/standards.html#Formatting 5.1 Formatting Your Source Code] chapter.
  
Additional SDCC rules:
+
== Additional SDCC specific rules: ==
 
*indent size = 2
 
*indent size = 2
 
*tab size = 8
 
*tab size = 8
 
*don't use tab characters in the source code, use spaces instead.
 
*don't use tab characters in the source code, use spaces instead.
 +
*do '''not''' commit purely stylistic changes as that would break the file history, which is worse than an inconsistent style. Instead consider ''fixing'' the style of individual subroutines when fixing the code itself as well.
  
All changes should be documented in the [http://www.gnu.org/prep/standards/standards.html#Change-Logs GNU style ChangeLog].
+
== Recommended Vim options: ==
 
+
Please do '''not''' commit purely stylistic changes as that would break the file history, which is worse than an inconsistent style. Instead consider ''fixing'' the style of individual subroutines when fixing the code itself as well.
+
 
+
== SDCC library source file license header ==
+
 
+
See [[SDCC library source file license header]].
+
 
+
== Recommended Vim options ==
+
  
 
To have [http://www.vim.org Vim] automatically format your code close to the desired coding style, add the following fragment to your $HOME/.vimrc (Unix) or $HOME/_vimrc (Windows):
 
To have [http://www.vim.org Vim] automatically format your code close to the desired coding style, add the following fragment to your $HOME/.vimrc (Unix) or $HOME/_vimrc (Windows):
Line 34: Line 29:
 
autocmd FileType c,cpp call SetupSDCC()
 
autocmd FileType c,cpp call SetupSDCC()
 
</pre>
 
</pre>
 +
 +
== Formatting with <tt>indent</tt> and <tt>astyle</tt> utilities: ==
  
 
The following commands reformat the source file in compliance with the preferred coding style:
 
The following commands reformat the source file in compliance with the preferred coding style:
Line 52: Line 49:
 
*use tab characters instead spaces where applicable in the source code
 
*use tab characters instead spaces where applicable in the source code
  
This is due that sdas and sdld are derived from ASxxxx and we want to keep the differences as small as possible in order to keep the merging simple.
+
This is due that sdas and sdld are derived from ASXXXX and we want to keep the differences as small as possible in order to keep the merging simple.
 +
 
 +
= ChangeLog coding style =
 +
 
 +
All changes should be documented in the [http://www.gnu.org/prep/standards/standards.html#Change-Logs GNU style ChangeLog].<br />
 +
 
 +
== Additional SDCC specific rules: ==
 +
 
 +
*use the TAB character for indentation.
 +
*follow the style of previous ChangeLog entries
 +
*don't forget to thank the author when applying a patch
 +
 
 +
= SDCC library source file license header =
 +
 
 +
See [[SDCC library source file license header]].
 +
 
 +
= SVN commits =
 +
 
 +
Add the commit comments when committing changes to the Subversion repository. Comments are usually same as ChangeLog entries with the leading TAB characters removed. For example see previous commit comments:
 +
<pre>
 +
svn log &lt;file_name&gt;
 +
</pre>
  
 
= SVN config settings =
 
= SVN config settings =
  
Use svn:eol-style=native attribute for newly added textual files to the SDCC svn repository. <br>
+
Use svn:eol-style=native attribute for newly added textual files to the SDCC svn repository.<br />
 
The preferred method is to apply the following settings to the svn conf file, located at:
 
The preferred method is to apply the following settings to the svn conf file, located at:
 
*Windows: C:\Documents and Settings\YourUserName\Application Data\Subversion\config
 
*Windows: C:\Documents and Settings\YourUserName\Application Data\Subversion\config
Line 178: Line 196:
 
ChangeLog = svn:eol-style=native;svn:keywords=Author Date Id Revision
 
ChangeLog = svn:eol-style=native;svn:keywords=Author Date Id Revision
 
</pre>
 
</pre>
 +
 +
[http://sourceforge.net/users/borutr/ Borut]

Latest revision as of 21:11, 25 December 2012

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox