I am wondering why the following two types
struct {
double re[2];
};
and
double re[2];
have the same size in C? Doesn’t struct add a bit of size overhead?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it just merely composes all the elements into one higher-level element whose size is merely the individual elements’ sizes added up (plus some padding depending on alignment rules, but that’s out of the scope of this question).