c++ - Why is the size of a native long primitive on 64-bit Windows only 4 bytes? -


will please tell me how makes sense, , how make stop? seriously, crazy or 64-bit windows long type 4 bytes? how make sense? thought native long primitive size supposed same native register size.

[32-bit linux]  me@u32:~$ ./sizes32 sizeof(char):      1 sizeof(short):     2 sizeof(int):       4 sizeof(long):      4 sizeof(long long): 8  [64-bit linux]  me@u64:~$ ./sizes64 sizeof(char):      1 sizeof(short):     2 sizeof(int):       4 sizeof(long):      8 sizeof(long long): 8  [32-bit windows]  c:\users\me\downloads>sizes32.exe sizeof(char):      1 sizeof(short):     2 sizeof(int):       4 sizeof(long):      4 sizeof(long long): 8  [64-bit windows]  c:\users\me\downloads>sizes64.exe sizeof(char):      1 sizeof(short):     2 sizeof(int):       4 sizeof(long):      4 sizeof(long long): 8 

backward compatibility!

windows came 16-bit platform sizeof(long) == 4 , makes extensive use of types long, dword... , changing make lot of code crash or not able compile

over on channel 9, member beer28 wrote, "i can't imagine there many problems programs have type widths changed." got chuckle out of , made note write entry on win64 data model.

the win64 team selected llp64 data model, in integral types remain 32-bit values , pointers expand 64-bit values. why?

in addition reasons give on web page, reason doing avoids breaking persistence formats. example, part of header data bitmap file defined following structure:

typedef struct tagbitmapinfoheader {         dword      bisize;         long       biwidth;         long       biheight;         word       biplanes;         word       bibitcount;         dword      bicompression;         dword      bisizeimage;         long       bixpelspermeter;         long       biypelspermeter;         dword      biclrused;         dword      biclrimportant; } bitmapinfoheader, far *lpbitmapinfoheader, *pbitmapinfoheader; 

if long expanded 32-bit value 64-bit value, not possible 64-bit program use structure parse bitmap file.

why did win64 team choose llp64 model?


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -