X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Date: Thu, 14 May 2015 18:20:26 +0300 From: "Eli Zaretskii (eliz AT gnu DOT org)" Subject: Re: bad pragma in dir.h? (and our structrure packing) In-reply-to: X-012-Sender: halo1 AT inter DOT net DOT il To: djgpp AT delorie DOT com Message-id: <83vbfvi3t1.fsf@gnu.org> References: <83k2wcjt8e DOT fsf AT gnu DOT org> <83bnhojnwh DOT fsf AT gnu DOT org> <838ucsjnbl DOT fsf AT gnu DOT org> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Date: Wed, 13 May 2015 23:27:39 +0300 > From: "Ozkan Sezer (sezeroz AT gmail DOT com)" > > > If you (or someone else) can verify that the size of the structure and > > the offsets of each member are the same in both C and C++ programs, > > then I see no reason to keep the attribute on every member. > > I did the following as a foo.c and foo.cc: > > #define COMPILE_TIME_ASSERT(name, x) \ > typedef int _djchk_ ## name[(x) * 2 - 1] > > #include "dos.h" > COMPILE_TIME_ASSERT(find_t,sizeof(struct _find_t)==286); > > #include "dir.h" > COMPILE_TIME_ASSERT(ffblk,sizeof(struct ffblk)==290); > COMPILE_TIME_ASSERT(ffblklfn,sizeof(struct ffblklfn)==318); > > #include "coff.h" > COMPILE_TIME_ASSERT(exln,sizeof(struct external_lineno)==6); > COMPILE_TIME_ASSERT(exse,sizeof(struct external_syment)==18); > COMPILE_TIME_ASSERT(exau,sizeof(union external_auxent)==18); > COMPILE_TIME_ASSERT(exrl,sizeof(struct external_reloc)==10); > > Compiled using existing and modified headers for djgpp using gcc/g++ > v3.4.6 and 5.1.0, no errors. I also compiled its coff.h-only parts > for linux (i686 gcc-4.3.0 and clang-3.4.2), osx (ppc gcc-4.0.1 and > x86_64 gcc-4.2.1), mingw (gcc-3.4.5), mingw-w64 (x86_64 gcc-4.5.4): > no errors. > > Diff for the modified headers is attached (1.patch) > Ideas? LGTM, thanks. > On 5/13/15, Andris Pavenis (andris DOT pavenis AT iki DOT fi) wrote: > > I guess it would be a good idea to have small test in build process to > > verify that offsets of > > members are correct for structures intended for DOS calls. So build would > > fail if something is > > wrong with member packing > > > > Andris > > We can add compile-time asserts like the above to the headers: ideas? I think a test in djtst would be better. Thanks.