Pergunta de entrevista da empresa NetApp

size of struct? platform dependency and architecture?

Resposta da entrevista

Sigiloso

27 de dez. de 2010

typedef struct xyz { char x; char *y; } With compiler padding, size would be 8 bytes on 32-bit architecture. The he asked how to avoid that. I gave solution to add # pragma pack (1) preprocessor to allow alignment on 1-bye boundary. He then asked what if I get size equal to 16. I rightly answered that it would be 64-bit architecture.. He then asked how do I remove platform depenency and make it portable on both system. I could not answer this question as i had no previous work experience with 64-bit application porting. He said that platform specific data types can be used. e.g u8, u16, u32 and int32, int64

2