struct struct0 {
int a;
};
struct struct1 {
struct struct0 structure0;
int b;
} rho;
&rho->structure0; /* Reference 1 */
(struct struct0 *)rho; /* Reference 2 */
(struct struct0)rho; /* Reference 3 */
-
From reference 1, does the compiler take the address of rho, and then access structure0, or vice-versa?
-
What does the line at reference 2 do?
-
Since structure0 is the first member of struct1, would reference 3 be equivalent to reference 1?
In order of your references:
->has higher precedence than the&. You’re going to get the address ofrho->structure0. Or rather, you would ifrhowere a pointer. Since it’s not, you’ll get a compile error.Your examples #2 and #3 are covered by the standard section 6.5.4:
If you put any of that code in a compiler you’d see the same results; is the code you’re showing not what you intended to ask about?