Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!axion!planet!pegasus!prk From: prk@planet.bt.co.uk (KnightRider) Newsgroups: comp.lang.c Subject: Re: Binary data file compatibility across machines Message-ID: Date: 26 Nov 90 13:15:26 GMT References: Sender: usenet@planet.bt.co.uk (Usenet News Manager) Organization: RT743, BT Research Labs, Martlesham Heath, Ipswich, UK. Lines: 38 stiber@cs.ucla.edu (Michael D Stiber) writes: >On different machines, the implementation of C data types is different. >I forget what fixed types' lengths are, but I know that at least some of >them may vary. I also know that doubles can have different encoding >schemes (ie, IEEE vs. DEC). Then, there's little endian machines versus >big endian ones. >So, my question is this: Say you want to share data files among >different machines. You also want to be able to use the same code on >each machine. Therefore, you want to have either a uniform file format, >or you want the code to be able to figure out what the file format is, >and convert it to the native data type representation. Now, one alternative >would be ASCII files --- this is guaranteed to work (assuming that you >can get C on an IBM 3090 to write ASCII). However, in my application, >ASCII would produce files that are way too huge --- I must use a binary >format. So, is there an already-existing, standard solution to this >problem of binary data file transfer? >-- > Michael Stiber > stiber@cs.ucla.edu > ...{ucbvax,ihpn4}!ucla-cs!stiber > UCLA Computer Science Dept. The short, easy, answer is yes - Use the facilities provided by the presentation layer services provided by your communications system, if you have one. For OSI systems this will ASN.1 -Abstract Syntax Notation 1. If you use Sun systems, you may be able to use XDR -External Data Representation. However, these are difficult services to encode, usually, so you may want to go to an external vendor to support these. Peter Knight BT Research #include