From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,669514ab3d2dbc39 X-Google-Attributes: gid1164f8,public X-Google-Thread: 1014db,669514ab3d2dbc39 X-Google-Attributes: gid1014db,public From: vosse@ruls41.fsw.LeidenUniv.nl (Theo Vosse) Subject: Re: Porting DOS C code to DEC Date: 1996/09/19 Message-ID: <4afumzgy9.fsf@ruls41.fsw.LeidenUniv.nl>#1/1 X-Deja-AN: 183939555 references: <51pqb5$gll@darla.visi.com> organization: Leiden University newsgroups: comp.sys.dec,comp.lang.c Hi, In article <51pqb5$gll@darla.visi.com> haverber@visi.com (Bill Haverberg) writes: ... I'm wondering what other incompatibilities exist between ANSI C code written for DOS as opposed to a UNIX environment...does anyone have any experience with this? Well, I have some experience, and in general everything that relies on the OS and on machine architecture is a potential incompatibility. E.g., if you rely on integers being a specific size (e.g. long int being 32 bits), you might be in for a surprise (on an Alpha they're 64 bits). Idem for pointer sizes. Also, relying on byte ordering in integers is dangerous... Binary file I/O should be compatible, but you cannot rely on file positions when using text file i/o to be the same. And then there are problems with floating point precision, which may make a certain algorithm run on one machine, but not on another. General library calls should also be compatible, but only minimally so. E.g., if you rely on malloc giving addresses in a certain order (e.g. from low to high), you might need to change code. Also, some calls, notably kbhit() en getkey(), are not (directly) available under Unix. I have also noted compiler quirks. E.g., one compiler was so anally retentive on being ANSI, that it had problems compiling calls to functions with an old style heading (the same holds for functions with variable arguments). It tended to cast everything to an int (which ANSI calls integral promotion), so I had some beautiful crashes. O yeah, something else: DOS file names are case insensitive, but under UNIX they aren't. So check your #includes. Also, on the #include-front, depending on what compiler you're used to, things like #include might be organized differently on UNIX machines. Oh well, porting from dos to unix is much simpler than the other way around... Summarizing: if you recompile hllowrld.c, you should not expect problems... Theo Vosse ---------- Unit for Experimental Psychology University of Leiden The Netherlands -- Theo Vosse ---------- Unit for Experimental Psychology University of Leiden The Netherlands