[問題] 結構指標的問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
gcc
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
程式碼:
typedef struct notify_buildreq_tag {
u32 id;
u32 state;} NOTIFY_BUILDREQ;
typedef struct notify_process_buildreq_result_tag {
u8 result;} NOTIFY_BUILDREQ_RESULT;
typedef struct notify_process_tag {
u32 state;} NOTIFY_PROCESS;
typedef struct notify_process_result_tag {
u8 result; u8 done;} NOTIFY_PROCESS_RESULT;
typedef struct notify_data_tag {
u8 type;
union {
NOTIFY_BUILDREQ bldReq;
NOTIFY_BUILDREQ_RESULT bldReqResult;
NOTIFY_PROCESS process;
NOTIFY_PROCESS_RESULT processResult;
} u;
u32 length; // length of the data that follows
uint32 addr_length;
char addr[16];
} NOTIFY_DATA;
main(){
NOTIFY_DATA * recvNotify;
recvNotify = (NOTIFY_DATA *) buf;
dprintf("[test2.1] ==> %x\n",(recvNotify));
dprintf("[test2] ==> %x\n",(recvNotify + 0x24));
}
餵入的資料(Input):
預期的正確結果(Expected Output):
倆著應該只差offset 0x24
錯誤結果(Wrong Output):
offset 510??
[test2.1] ==> 814361e8
[test2] ==> 814366f8
問題
為什麼兩者的差距不適0x24?
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.22.66.242
→
07/21 20:22, , 1F
07/21 20:22, 1F
→
07/22 03:21, , 2F
07/22 03:21, 2F
→
07/22 03:22, , 3F
07/22 03:22, 3F
→
07/22 04:03, , 4F
07/22 04:03, 4F
→
07/22 04:05, , 5F
07/22 04:05, 5F
→
07/22 04:06, , 6F
07/22 04:06, 6F
→
07/22 04:07, , 7F
07/22 04:07, 7F
→
07/22 09:44, , 8F
07/22 09:44, 8F
→
07/22 10:03, , 9F
07/22 10:03, 9F
→
07/22 10:04, , 10F
07/22 10:04, 10F
→
07/22 10:08, , 11F
07/22 10:08, 11F