내가 비주얼 C에서이 구조체를 사용하려면 ++에서 문제 :비트 필드의 Visual C++
struct iphdr
{
unsigned int ihl:4;
unsigned int version:4;
u_int8_t tos;
u_int16_t tot_len;
u_int16_t id;
u_int16_t frag_off;
u_int8_t ttl;
u_int8_t protocol;
u_int16_t check;
struct in_addr ip_src;
struct in_addr ip_dst;
};
그러나 디버깅 나는 20
될 것으로 예상 sizeof(struct iphdr) = 24
을 발견하고 내가 교체 할 때하는 것이 이상하다 ihl
및 version
char
와, sizeof(struct iphdr) = 20
32 비트 또는 64 비트 컴파일러에서 컴파일하고 있습니까? –
일반적인 구조체 맞춤/패딩 것 이상의 의미가있는 것 같습니다. – Mysticial
@izomorphius 아니요, 32 비트 컴파일러이고 vC++ 2008을 사용하고 있습니다 – Javran