TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Rule:  6.5.2.3.dChecked automatically with code checker

Synopsis:Do not use nested structures.
Language:C
Severity Level:6
Category:Expressions


Description:

Justification

The scoping rules between C and C++ structures are different. The fields of a nested structure are directly accessible in C, but not in C++. So using nested structures might thus result in different and unexpected behavior.

Example

typedef struct {
  int size;
  struct {
    int x;
    int y;
  } Point;
} Mystruct; /* WRONG */

typedef struct {
  int x;
  int y;
} Point;

typedef struct {
  int size;
  Point p;
} Mystruct; /* RIGHT */