[Crossfire-wiki] [Crossfire DokuWiki] page changed: coding_style_guide

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Mon Sep 3 23:23:32 CDT 2007


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2007/09/03 23:23
User        : kbulgrien
Edit Summary: Delete leading spaces for copy/paste examples; Add for/while/switch to if () rule.

@@ -25,49 +25,49 @@
    - Assume all names use one name space.  For example, if there is a //struct// called ''spell'', don't make the name of an optional parameter spell. This will break on ANSI C compilers that follow the spec strictly (gcc does not, even with -strict -ansi)
    - As a followup on 9 above, do not use non-standard gcc extensions (%%//%% for comment lines, ability to nest functions, declare arrays with variable bounds, etc.)  Likewise, do not use special system functions, for example, do not assume the target is a BSD or SVR4 system.  If a potentially non-standard function must be used, add checks in the autoconf script and include a version of the function in case it is not on that system.  The keyword here is portability; do not assume everyone else has the same system you have.
    - Write code that can easily be maintained in the future, not code that is easiest to write quickly.  In other words, do not do the quick and dirty hack, but instead always write code with maintainability and clarity in mind.
    - Use 4 space indentation.  While a lot of old code may use 2 spaces, a move to 4 spaces makes readability easier.
-   - Files are created with standard content blocks.<code> char *rcsid_component_file_ext =
-      "$Id: file.ext$";
-  /*
-   * Project name, brief description
-   *
-   * Copyright information
-   *
-   * GPL blurb here
-   *
-   * Contact information
-   */
+   - Files are created with standard content blocks.<code>char *rcsid_component_file_ext =
+     "$Id: file.ext$";
+ /*
+  * Project name, brief description
+  *
+  * Copyright information
+  *
+  * GPL blurb here
+  *
+  * Contact information
+  */
  
-  /**
-   * @file file.ext
-   * A brief description.  Detailed information may follow.
-   */</code>
+ /**
+  * @file file.ext
+  * A brief description.  Detailed information may follow.
+  */</code>
      * The //rcsid_// variable is useful for creating error and debug messages.  For //component//, look at other files nearby. 
      * The @file comment block helps doxygen create meaningful output.
      * The license block requirement is obvious.
-   - Functions are documented like this.<code> /**
-   * A brief descriptive sentence summarizes the function.  An overview ends
-   * at the first period and space, then the detailed information follows.
-   *
-   * @param bla
-   * This is a parameter
-   * @return
-   * returns NULL
-   */</code>
+   - Functions are documented like this.<code>/**
+  * A brief descriptive sentence summarizes the function.  An overview ends
+  * at the first period and space, then the detailed information follows.
+  *
+  * @param bla
+  * This is a parameter
+  * @return
+  * returns NULL
+  */</code>
      * This lets doxygen generate nice documentation.
-   - Use the following block commenting style.<code> /*
-   * Do block comments like this.
-   * Get in the habit of using a
-   * brief and detailed style.
-   */
+   - Use the following block commenting style.<code>/*
+  * Do block comments like this.
+  * Get in the habit of using a
+  * brief and detailed style.
+  */
  
-   /*
-     and not
-     like this
-    */
+ /*
+   and not
+   like this
+  */
  
-   /* but single line comment using this method is fine */</code>
+ /* but single line comment using this method is fine */</code>
      * It is much easier to spot the block comments if they all start with *, and they tend to be worth noticing.
    - As discussed on irc, the preferred style for expressions is like this:<code>
  if (expression) {
    statement;
@@ -78,8 +78,9 @@
  {
    statement;
    statement;
  }</code>
+     * Also applies to for (), switch (), and while ().
    - The preferred style of formal parameters:<code>
  void myFooFunction(param1, param2, param3) {
    statement;
    statement;


IP-Address  : 66.137.82.229
Old Revision: http://wiki.metalforge.net/doku.php/coding_style_guide?rev=1188855921
New Revision: http://wiki.metalforge.net/doku.php/coding_style_guide

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list