简体   繁体   中英

Does order of variables in struct for win64 matter?

So I was working with socket programming in windows and I came upon this struct.

#define WSADESCRIPTION_LEN  256
#define WSASYS_STATUS_LEN   128

typedef struct WSAData {
    WORD        wVersion;
    WORD        wHighVersion;
#ifdef _WIN64
    unsigned short  iMaxSockets;
    unsigned short  iMaxUdpDg;
    char        *lpVendorInfo;
    char        szDescription[WSADESCRIPTION_LEN+1];
    char        szSystemStatus[WSASYS_STATUS_LEN+1];
#else
    char        szDescription[WSADESCRIPTION_LEN+1];
    char        szSystemStatus[WSASYS_STATUS_LEN+1];
    unsigned short  iMaxSockets;
    unsigned short  iMaxUdpDg;
    char        *lpVendorInfo;
#endif
} WSADATA, *LPWSADATA;

You can see the struct members are same for each condition only the placement is different.

Why actually is this done? Is it relevant to new programmers like me?

and can I just carry on my tasks without any worry or should I look upon this more seriously?

Does order of variables in struct for win64 matter?

Only for padding.

Is it relevant to new programmers like me?

Don't think about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM