www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/07/08:47:04

Xref: news2.mv.net comp.os.msdos.djgpp:6705
From: alaric AT abwillms DOT demon DOT co DOT uk (Alaric B. Williams)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP v2
Date: Tue, 30 Jul 1996 17:11:52 GMT
Lines: 50
Message-ID: <838746602.16082.5@abwillms.demon.co.uk>
References: <Pine DOT LNX DOT 3 DOT 91 DOT 960729023100 DOT 17208I-100000 AT blackwidow DOT saultc DOT on DOT ca> <31FC7D41 DOT 4E74 AT dsys DOT ceng DOT cea DOT fr>
NNTP-Posting-Host: abwillms.demon.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Eric NICOLAS <nicolas AT dsys DOT ceng DOT cea DOT fr> wrote:
>You simply cannot share binary files between BC and DJGPP.

RED ALERT

Never say never.

The trick is to do this:

Original BC struct fwritten:

struct Thing {
	char name[40];
	int x;
	long int y;
	short int z;	
};

Long and Short ints are the same in DJGPP as BC.

BCC Ints are the same as Short Ints, DJGPP Ints are the same as Long
Ints.

DJGPP pads structures for a Technical Reason, which must be disabled.

DJGPP version of the struct to fread from the file:

#pragma pack(1)

struct Thing {
	char name[40];
	short int x;    //The only change
	long int y;     //could be written just "int y"
	short int z;	
};

#pragma pack()

Tada! A SHARED BINARY FILE!

Regards,


ABW
--
I have become... Comfortably numb...

Alaric B. Williams Internet : alaric AT abwillms DOT demon DOT co DOT uk
<A HREF="http://www.hardcafe.co.uk/Alaric/">http://www.hardcafe.co.uk/Alaric/</A>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019