Microsoft Visual C++ 6.0 an Error or what the....
I defined a structure with like the fallowing one
struct myStruct
{
short int a;
int b;
short int c;
short int d;
int e;
};
This structure is 14Bytes long, i then tried the fallowing code
void main(void)
{
printf("sizeof(myStruct) = %d\r\n", sizeof(myStruct));
}
and the program returned 16Bytes.
The compiler i use is MSVC++ 6.0 publishers edition (this version shipped with the game developing starter kit)
under Win98 (PIII 450, 196MB, DirectX 8, Geforce 256)
does someone know anything about this problem our stuff related to this
The compiler is adding padding to the structure so that it is DWORD aligned, making it more efficient.
[Resist Windows XP''s Invasive Production Activation Technology!]
[Resist Windows XP''s Invasive Production Activation Technology!]
Structures are commonly padded to align on 4byte boundries. It is possible to turn this off.
Mike
Mike
Right, to turn this off, go to project menu, settings, c/c++ tab, bring down code generation and change your struct member alignment. Mine seems to align on 8 byte bounries on default.
Mike
Mike
Or:
#pragma pack(push,1)
struct
{
jada jada
};
#pragma pack(pop) // back to the old size
/McFly
Edited by - mcfly on September 21, 2001 9:58:12 PM
#pragma pack(push,1)
struct
{
jada jada
};
#pragma pack(pop) // back to the old size
/McFly
Edited by - mcfly on September 21, 2001 9:58:12 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement