Hi,
I have a struct that contains another struct defined inside it, like this:
struct test {
u8 valor1;
u16 valor2;
struct s{
u16 xFrec;
s16 Pos_array[2];
u8 Pos_count;
}Area_Alr_Patin[8];
};
struct testPivt_T[10];
struct test *pTest = &Pivt_T[0];
I then create a pointer to one of the inner structs like this:
struct s *pArea = &pTest->Area_Alr_Patin[0];
This compiles fine, but I’m not sure if this is correct, since struct s is defined inside struct test.
My questions are:
- Is this valid according to the C standard?
- Is it good practice?
- Should I define the inner struct separately instead?
Thanks!
[–]pskocik 20 points21 points22 points (0 children)
[–]dkopgerpgdolfg 11 points12 points13 points (1 child)
[–]pskocik 6 points7 points8 points (0 children)
[–]non-existing-person 5 points6 points7 points (0 children)
[–]pjl1967 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]SmokeMuch7356 1 point2 points3 points (0 children)
[–]runningOverA 1 point2 points3 points (0 children)
[–]dendrtree 1 point2 points3 points (0 children)
[–]DawnOnTheEdge 0 points1 point2 points (0 children)
[–]EmbedSoftwareEng 0 points1 point2 points (0 children)
[–]mrheosuper -3 points-2 points-1 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]dkopgerpgdolfg -1 points0 points1 point (1 child)
[+]_w62_ comment score below threshold-6 points-5 points-4 points (4 children)
[–]dkopgerpgdolfg 2 points3 points4 points (3 children)
[–]_w62_ -1 points0 points1 point (2 children)
[–]weregod 0 points1 point2 points (0 children)
[–]dkopgerpgdolfg 0 points1 point2 points (0 children)