Mail Archives: djgpp/1997/02/15/01:36:24
Hi, there :
I'm just wondering whether it works or not if :
#pragma pack(1);
#include <grx20.h>
I've test the following data structure with/without #pargma pack(1);
struct _GR_videoModeExt {
enum _GR_frameModes mode;
struct _GR_frameDriver *drv;
char far *frame;
char cprec[3];
char cpos[3];
int flags;
int (*setup)(GrVideoMode *md,int noclear);
int (*setvsize)(GrVideoMode *md,int w,int h,GrVideoMode *result);
int (*scroll)(GrVideoMode *md,int x,int y,int result[2]);
void (*setbank)(int bk);
void (*setrwbanks)(int rb,int wb);
void (*loadcolor)(int c,int r,int g,int b);
};
I use the following line to show the difference :
printf("sizeof(cprec+cpos)=%d\n",
(unsigned)(&st.flags)-(unsigned)(&st.cprec[0]));
* With #pragma pack(1);
sizeof(cprec+cpos)=6
* Without #pragma pack(1);
sizeof(cprec+cpos)=8
Such a problem should occurred in many places, such as read/write
data files,
linking CodeBase...etc
My question is this :
1. Is there a chance that I might link my code with "libgrx20.a" with
this
different #pragma ?
2. If the offset of each field is important, should I rebuild EACH
LIBRARY
with different #pragma setting ????!!!!
3. Or, there is a gcc command line option for this ?
Sorry if this is a dumb question... :-P
since this problem is critical to my program ... Thanks !
Luke
- Raw text -