Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: vosse@ruls41.fsw.LeidenUniv.nl (Theo Vosse)
Subject: Re: Porting DOS C code to DEC
Date: 1996/09/19	[thread overview]
Message-ID: <4afumzgy9.fsf@ruls41.fsw.LeidenUniv.nl> (raw)
In-Reply-To: 51pqb5$gll@darla.visi.com


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 <sys/types.h> 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



  parent reply	other threads:[~1996-09-19  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-18  4:00 Porting DOS C code to DEC Bill Haverberg
1996-09-19  4:00 ` Ron Natalie
1996-09-19  4:00 ` Theo Vosse [this message]
1996-09-19  4:00   ` Szu-Wen Huang
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox