diff --git a/Documentation/NuttXCCodingStandard.html b/Documentation/NuttXCCodingStandard.html index 977af36225b..98c878a2964 100644 --- a/Documentation/NuttXCCodingStandard.html +++ b/Documentation/NuttXCCodingStandard.html @@ -12,7 +12,7 @@

NuttX C Coding Standard

-

Last Updated: February 9, 2017

+

Last Updated: April 17, 2017

@@ -1291,14 +1291,23 @@ typedef int myinteger_t;
  • No un-named structures. All structures must be named, even if they are part of a type definition. + That is, a structure name must follow the reserved word struct in all structure definitions. The exception to this rule is for structures that are defined within another union or structure. In those cases, the structure name should always be omitted.
  • +
  • + No un-named structure fields. + Structure may contain other structures as fields. + This this case, the structure field must be named. + C11 permits such un-named structure fields within structure. + NuttX generally follows C89 and all code outside of architecture specific directories must be compatible with C89.
  • No structure definitions within Type Definition. The practice of defining a structure within a type definition is discouraged. It is preferred that the structure definition and the type definition be separate definitions. In general, the NuttX coding style discourages any typdef-ing of structures; normally the full structure name is used as types throughout the code. + The reason for this is that is structure pointers may be forward referenced in header files without having to include the file the provides the type definition. + This greatly reduces header file coupling.
  • Short structure names. @@ -1373,7 +1382,7 @@ typedef int myinteger_t;

    Incorrect

    @@ -1396,23 +1417,35 @@ struct xyz_information struct xyz_info_s { ... - int val1; /* Value 1. */ - int val2; /* Value 2. */ - int val3; /* Value 3. */ + int val1; /* Value 1 */ + int val2; /* Value 2 */ + int val3; /* Value 3 */ ... };
    -typdef struct xyz_info_s xzy_info_t;
    +typedef struct xyz_info_s xzy_info_t;
     

    (The use of typedef'ed structures is acceptable but discouraged)

     struct xyz_info_s
     {
       ...
    -  uint8_t bita : 1,  /* Bit A. */
    -  uint8_t bitb : 1,  /* Bit B. */
    -  uint8_t bitc : 1,  /* Bit C. */
    +  uint8_t bita : 1,  /* Bit A */
    +  uint8_t bitb : 1,  /* Bit B */
    +  uint8_t bitc : 1,  /* Bit C */
    +  ...
    +};
    +
    +struct abc_s
    +{
    +  ...
    +  struct
    +  {
    +    int a;           /* Value A */
    +    int b;           /* Value B */
    +    int c;           /* Value C */
    +  } abc;
       ...
     };
     
    @@ -1433,13 +1466,18 @@ struct xyz_info_s

    Example

    @@ -1456,9 +1494,9 @@ struct xyz_info_s

    NOTE: - Note that the union name u is used often. + Note that the union fields within structures are often named u. This is another exception to the prohibition against using single character variable and field names. - The short field name u clearly identifies a union field and prevents the full name to the union value from being excessively long. + The short field name u clearly identifies a union field and prevents the full name of the union value from being excessively long.

    2.7 Enumerations