Nov 12, 2010 at 1:18pm UTC
Hello ,
I had a program which was crashing in HP IA 64 bit machine.
My program is configured for 4 byte alignment( #pragma pack(4)).
The same program didnt crash when configured for 8 byte alignment( #pragma pack(8))
Program was like this :
typedef enum comp
{
comp1=-1,
comp2,
comp3=0xFFFFFFF
}
typedef struct str1
{
comp nComp;
FunPtr nfunptr1;(Function pointer )
FunPtr nfunptr2;(Function pointer )
}str;
Structure str has a initialization as below :
str gStr[10]
= {
{comp(-1),mfunptr1,0L},
{comp(-1),mfunptr1,0L},
..
..
{comp(-1),mfunptr1,0L},
{comp(-1),mfunptr1,0L}
}
The above program used to crash.
But when i changed the code as below it didnt crash.
But i didnt understand why ?
typedef struct str1
{
FunPtr nfunptr1;/*Function pointer*/
FunPtr nfunptr2;/*Function pointer*/
comp nComp;
unsigned int PaddByte;/*Padding 4 byte*/
}str;
str gStr[10]
= {
{mfunptr1,0L},
{0L,mfunptr1,comp(-1)},
..
..
{0L,mfunptr1,comp(-1)},
{0L,mfunptr1,comp(-1)}
}
Please help me understand this ......