tbastian
May 25th, 2010, 05:05 PM
I have a structure which I need to know the size of. I wrote this test program.
#include <stdio.h>
#include <stdint.h>
#pragma pack ( 1 )
typedef struct {
uint16_t header_word;
uint16_t size;
uint8_t major_no;
uint8_t minor_no;
uint16_t trailer_word;
} header_t;
#pragma pack ()
int main ( int argc, char ** argv )
{
header_t header;
printf ( "header_t %d\n", sizeof ( header ));
return 0;
}
sizeof (header) returns 8, not 64! why?
#include <stdio.h>
#include <stdint.h>
#pragma pack ( 1 )
typedef struct {
uint16_t header_word;
uint16_t size;
uint8_t major_no;
uint8_t minor_no;
uint16_t trailer_word;
} header_t;
#pragma pack ()
int main ( int argc, char ** argv )
{
header_t header;
printf ( "header_t %d\n", sizeof ( header ));
return 0;
}
sizeof (header) returns 8, not 64! why?