Portable Code

Powell jdp at adiron.UUCP
Thu Jul 28 03:36:43 AEST 1988


In article <1157 at radio.toronto.edu>, brian at radio.toronto.edu (Brian Glendenning) writes:
> 
> I am currently involved with porting/extending a networked graphics server I
> wrote for Sun 3 machines to Iris workstations, and it will likely be ported to
> new machines in the future.
> ...
> Some issues that could be addressed:
> 
>         1) Byte order and type size differences. What is the best way for
>            dealing with these? What are the "gotcha"'s?

I use a conversion program to transfer data files from one machine
to another.  dd conv=swab is sufficient for short data.  Long, float, and
double are a different story.
I use sizeof (variable) rather than sizeof (type) whenever possible.

>         2) BSD/SysV/whatever differences. What assumptions are likely to
>            lead me into trouble?

I have not dealt with this too much.

>         3) Source code management: what's the best way to maintain codes that
>            run on a variety of machines. #ifdef MACHINE_TYPE? Never or rarely 
>            use #ifdef, edit makefiles? ???

I use #if defined(XXX) for each machine type.  The XXX is sun for SUNs,
vax for VAXEN and sgi for Iris (I assume this is the SILICON GRAPHICS IRIS).
The symbol sgi is predefined on SILICON GRAPHICS IRIS system.

Watch out for differences in include file names and types.  On the
version I used, the struct direct went with read(), struct dirent went
with readdir().  Not exactly what I expected.

> 	4) Everything I've forgotten :-)

The only displayable data type on the Iris I worked with was "short".
Byte data had to be converted to short before interfacing to the graphics
routines.

Position (0,0) on Iris is the lower left corner.  Position (0,0) on the
SUN is the upper left corner.

The Iris has at least 2 modes of operating within graphics.  One requires
their window manager and one disallows the window manager.  It is possible
within the program to determine which mode you're in.  The routines to
be used in either case are completely different.

Iris operates as if it were in the SUN mode in which "click-to-type"
was true.  Moving the cursor does not detach control from a particular
window.

Fortran and C mixtures require bridge functions.  The Fortran and C
interface is entirely different from Berkeley.

Good luck.


					John D. Powell
					PAR Technology



More information about the Comp.lang.c mailing list