Does order of variables in struct for win64 matter?

57 views Asked by At

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?

1

There are 1 answers

0
TheRyuTeam On

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.