C++ 5.0 and sizeof (struct) / padding ? 
Author Message
 C++ 5.0 and sizeof (struct) / padding ?

I have to build a program, that creates a binary file, that should be
read in a MSC 6.0 based program.
I have used the same structure definitions, but the sizeof operator
always gives me a wrong size.The first problem was, that "int" in MSC6
only is a 16 bit type, but in C++ 5.0 a 32 bit type. this was solved in
replaing all int types with short type. But still I get wrong values,
presumably because of the different block sizes (Padding).
Is ther any possiblity to overcome this problem ,as my binary file still
cannot be read.
Thanks for your help.
Dietmar Kreusel
Taylor Hobson GmbH



Tue, 11 Jan 2000 03:00:00 GMT  
 C++ 5.0 and sizeof (struct) / padding ?

Try adding the "#pragma pack(n)" directive to insure that both programs are
aligning the structure the same way.

Bob.



Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. struct padding and sizeof

2. sizeof(struct) and padding

3. sizeof (struct) ! = sizeof struct elements

4. SizeOf Misreporting Struct w/ Bitfield, Union, and Nested Struct

5. padding in a statically initialized struct

6. Padding in structs

7. padding a struct to a defined size

8. padding in structs..

9. padding in structs

10. Q: howto prevent struct padding

11. create a padded struct?

12. MS Visual C++ 5.0 or Borland C++ 5.0?

 

 
Powered by phpBB® Forum Software