Xref: news-dnh.mv.net comp.os.msdos.djgpp:4173 Path: news-dnh.mv.net!mv!news.sprintlink.net!usenet.kornet.nm.kr!news.kreonet.re.kr!overload.lbl.gov!lll-winken.llnl.gov!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!EU.net!Portugal.EU.net!news.rccn.net!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!news.uni-c.dk!diku.dk!terra From: terra AT diku DOT dk (Morten Welinder) Newsgroups: comp.os.msdos.djgpp Subject: Re: Structure sizing problem Date: 7 Jan 1996 14:35:36 GMT Organization: Department of Computer Science, U of Copenhagen Lines: 29 Sender: terra AT tyr DOT diku DOT dk Message-ID: <4colno$dc0@odin.diku.dk> References: <4cofrl$7d3 AT news DOT mdata DOT fi> NNTP-Posting-Host: odin.diku.dk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp @megabaud.fi writes: >struct main_directory_entry { > char name[7]; > unsigned long offset; > unsigned long size; >}; >Borland C++ returns sizeof(main_directory_entry)=15 and >djgpp returns 16, which causes little problems with >file-reading routines... >However when I tested sizeof(main_directory_entry.name) it returned >7 and unsigned longs returned 4. 7+4+4=15 isn't it? Certainly, but 7+1+4+4 is 16. gcc aligns longs for faster access. >Have I missed some piece of information or is this a bug in compiler? The memory layout is implementation dependent. You can get the packed behaviour by adding the "packed" attribute. See the source file src/debug/fsdb/fullscr.c for an example of how to do it. Morten PS: fix your email return address.