I am getting unexpected result for the below code.
union
{
int aBuf[RMH_MAX_UNENCODED_LENGTH+sizeof(MSG_INFO)]; //4070+68=4138
}sUnion;
NSLog(@"%d",sizeof(sUnion.aBuf));//printing as 16552 and not 4138
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.
That is the correct output for this code. Your union contains an array of 4138
inttypes. If you ranNSLog(@"%d",sizeof(int));, the output would be4. 4*4138=16552, so an array of 4138ints is 16552 bytes long.