From: Luke Lee Newsgroups: comp.os.msdos.djgpp Subject: #pragma pack(1) and ? Date: Fri, 14 Feb 1997 15:21:20 +0800 Organization: Common Forth Labortory Lines: 50 Message-ID: <33041270.30ED@ms2.hinet.net> Reply-To: comforth AT ms2 DOT hinet DOT net NNTP-Posting-Host: @140.109.249.6 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi, there : I'm just wondering whether it works or not if : #pragma pack(1); #include 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