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 @@
Last Updated: February 9, 2017
+Last Updated: April 17, 2017
@@ -1291,14 +1291,23 @@ typedef int myinteger_t;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.
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.
Incorrect
-typedef struct
+typedef struct /* Un-named structure */
{
...
int val1, val2, val3; /* Values 1-3 */
@@ -1388,6 +1397,18 @@ struct xyz_information
bitc : 1; /* Bit C */
...
};
+
+struct abc_s
+{
+ ...
+ struct
+ {
+ int a; /* Value A */
+ int b; /* Value B */
+ int c; /* Value C */
+ }; /* Un-named structure field */
+ ...
+};
-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
-union xyz_union_u
+union xyz_union_u /* All unions must be named */
{
- uint8_t b[4]; /* Byte values. */
- uint16_t h[2]; /* Half word values. */
- uint32_t w; /* Word Value. */
+ uint8_t b[4]; /* Byte values. */
+ uint16_t h[2]; /* Half word values. */
+ uint32_t w; /* Word Value. */
};
-
+
++typedef union xyz_union_u xzy_union_t; ++
(The use of typedef'ed unions is acceptable but discouraged)
+
struct xyz_info_s
{
...
@@ -1448,7 +1486,7 @@ struct xyz_info_s
uint8_t b[4]; /* Byte values. */
uint16_t h[2]; /* Half word values. */
uint32_t w; /* Word Value. */
- } u;
+ } u; /* All union fields must be named */
...
};
@@ -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.