// JP opened flex table

Click to See Complete Forum and Search --> : Compiler/Link assign different size to same global object


LMS
March 15th, 2000, 10:08 AM
I have 100K SLOC app that compiles/links fine on Dec Alpha. When I compile/link the code on Intel platform, I find that a few global class objects are larger in the compilation (per watch window "sizeof") than what the link load map shows. Now the difference I infer to be due to alignment padding. Nonetheless, in one case the compiler generates object with 40 byte size, and load map shows 36 bytes! I haven't produced this in a small app yet. The compilation settings have 8 byte alignment. Any ideas on how to force linker to give 8 byte doubleword alignment as default for Intel? I'm using SP3. (Alpha Dev Studio uses double word boundaries for ALL globals.) Appreciate your experiences learned...

LMS

nikb
March 20th, 2000, 10:08 AM
Have you tried to rebuild the whole project from scratch? Sometimes, things can get out of synch, and this sort of thing is typical of what may occur in that case...

Certainly, it is legal for a structure to be bigger in size, than the sum of sizes of its members, due to padding, as you mentioned...

However, for the load map to actually display it as smaller, is certainly not good...

-n

pmatt
March 20th, 2000, 05:22 PM
I use #pragma pack(nBytes) with an argument of 1 to cause structures to be byte-aligned when handling data input from certain devices. You could use this to cause your structures to be aligned on 8-byte boundaries as well.

You can also use the /Zp option to set the packing level for the entire comiplation unit (i.e. /Zp8).

Hope this helps.

-p

LMS
March 20th, 2000, 07:14 PM
The hint to check pragma pack usage got me to ensure that I'd pushed and popped in pairings. Recently I'd added another vendor's interface to my program, and lo' and behold but they gave me an include file with just a "#pragma pack(1)" -- with no resetting of packing at end -- Once I reset to original settings at end of their include file, it works just fine. Thanks for your help.

LMS

//JP added flex table