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 */ |