Added coding style document. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Fri, 28 Oct 2011 11:31:54 +0200
branchstable-1.5
changeset 2125 af3eda069078
parent 2124 c4afc5fede19
child 2128 e645d0d83b3b
Added coding style document.
CodingStyle.txt
README
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CodingStyle.txt	Fri Oct 28 11:31:54 2011 +0200
@@ -0,0 +1,44 @@
+$Id$
+
+vim: spelllang=en tw=78
+
+This is a short introduction to the coding style that shall be used. The below
+rules are applicable for all C source files, except the Ethernet drivers, for
+which the Linux Kernel coding style shall be used to minimize the
+differences).
+
+* Lines shall not exceed 78 characters.
+
+* Indentation shall be done using 4 space characters
+
+* No whitespace shall be left at the end of a line.
+
+* After a comma, a single space shall be placed (if not followed by a
+  line break).
+
+* Braces shall be placed in the following way (K&R style):
+
+    if (...) {
+        ...
+    } else if (...) {
+        ...
+    } else {
+        ...
+    }
+
+    int function(...)
+    {
+        ...
+    }
+
+* Macros shall be named in CAPITAL letters. If a macro contains multiple
+  statements, they should be enclosed by a 'do {} while (0)' loop. Macro
+  parameters shall also be capital letters and shall be enclosed py parantheses
+  if necessary.
+
+    #define MACRO(A, B) \
+        do { \
+            if ((A) == 1) { \
+                statement(B); \
+        } while (0)
+
--- a/README	Mon Oct 24 10:49:27 2011 +0200
+++ b/README	Fri Oct 28 11:31:54 2011 +0200
@@ -1,4 +1,4 @@
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 This is the README file of the IgH EtherCAT Master.
 
@@ -6,7 +6,7 @@
 
 vim: spelllang=en spell tw=78
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 Contents:
 1) General Information
@@ -14,8 +14,9 @@
 3) Building and installing
 4) Realtime & Tuning
 5) License
+6) Coding Style
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 1) General Information
 ======================
@@ -33,7 +34,7 @@
 D-45356 Essen
 http://igh-essen.com
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 2) Requirements
 ===============
@@ -48,27 +49,27 @@
 A table of supported hardware can be found at
 http://etherlab.org/en/ethercat/hardware.php.
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 3) Building and installing
 ==========================
 
 See the INSTALL file.
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 4) Realtime & Tuning
 ====================
 
 Realtime patches for the Linux kernel are supported, but not required. The
 realtime processing has to be done by the calling module (see API
-documentation). The EtherCAT master code itself is passive (except for the idle
-mode and EoE).
+documentation). The EtherCAT master code itself is passive (except for the
+idle mode and EoE).
 
 To avoid frame timeouts, deactivating DMA access for hard drives is
 recommended (hdparm -d0 <DEV>).
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 
 5) License
 ==========
@@ -96,4 +97,11 @@
 technology and brand is only permitted in compliance with the industrial
 property and similar rights of Beckhoff Automation GmbH.
 
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+
+6) Coding Style
+===============
+
+Developers shall use the coding style rules in the CodingStyle.txt file.
+
+------------------------------------------------------------------------------