구조체 sizeof를 하면 틀리게 나오는 이유...
권시크
구조체 sizeof를 하면 틀리게 나오는 이유...구조체를 만들고 들어온 값을 memcpy하여 구조체 변수를 불러다 쓰다보니 한개씩 밀리는 경우 가 발생하여 sizeof를 보니 틀리게 나옵니다. 질문 내용 : 먼저 헤더 파일에 다음과 같이 define해놓았습니다.
typedef unsigned char boolean; /* boolean value type. */
typedef unsigned long long uint64; /* unsigned 64 bit value */
typedef unsigned long int uint32; /* unsigned 32 bit value */
typedef unsigned short uint16; /* unsigned 16 bit value */
typedef unsigned char uint8; /* unsigned 8 bit value */
typedef signed long int int32; /* signed 32 bit value */
typedef signed short int16; /* signed 16 bit value */
typedef signed char int8; /* signed 8 bit value */
/* this group are the deprecated types. their use should be
** discontinued and new code should use the types above
*/
typedef unsigned char byte; /* unsigned 8 bit value type. */
typedef unsigned short word; /* unsinged 16 bit value type. */
typedef unsigned long dword; /* unsigned 32 bit value type. */
typedef unsigned char uint1; /* unsigned 8 bit value type. */
typedef unsigned short uint2; /* unsigned 16 bit value type. */
typedef unsigned long uint4; /* unsigned 32 bit value type. */
typedef signed char int1; /* signed 8 bit value type. */
typedef signed short int2; /* signed 16 bit value type. */
typedef long int int4; /* signed 32 bit value type. */
typedef signed long sint31; /* signed 32 bit value */
typedef signed short sint15; /* signed 16 bit value */
typedef signed char sint7; /* signed 8 bit value */
구조체는 다음과 같습니다.
typedef struct s_any_debug_type
{
uint16 frequency; // center frequency channel
uint16 psc;
int16 rssi;
uint16 drx_cycle_len;
byte plmn[6];
byte cn_id;
byte mm_state;
byte rrc_state;
byte net_op_mode;
byte imsi[16];
int16 tx_pwr;
int16 rscp;
int16 ecio;
byte lac[2];
byte rac;
/*
any_bler_type bler;
int16 ktf_tx_adj;
byte gmm_state;
byte pathloss;
uint32 cell_id;
uint16 measurement_rscp;
*/
}any_debug_type ;
위에서 구조체를 sizeof로 해서 구해보면 lac[2]까지는 42가 나오는데..rac를 하게되면 44가 나옵니다. 43이 나와야 하는데..왜 그런건가요...?