[comp.sys.amiga] Porting from C to C - hints

gary@mit-eddie.MIT.EDU (Gary Samad) (12/17/86)

I have noticed many postings from people groaning about having trouble
porting code between Manx and Lattice.  I have done this a few times and
thought I'd give y'all a few hints...

Lattice --> Manx:

If you just want to get something up and don't care about the 16 bit Manx
integers, here is what you have to do:

Compile with the +L option (to get 32 bit ints)
Link with the 32 bit library - ln foo.o -lc32
And this is the trick that many people probably miss:  in the source, include
the line:  #include <functions.h>
This includes a definition file that comes with the Manx compiler that defines
(almost) all of the system function calls and will help you avoid all of those
"INVALID PTR/INT CONVERSION" messages from the compiler.
The only other problems I've encountered are 1) not ALL of the system functions
are defined in functions.h, so just define them at the top of your source;
2) sometimes a Lattice function is used that Manx doesn't support, but I've
always found a Manx alternative (e.g. sscanf instead of ssch_i(or something
like that)) is available.

If you want to get the Manx 16 bit ints, it takes more work.  If the original
code was written with this in mind (defining ints as long when necessary),
it is a fairly easy port.  I managed to port the IFF routines that came from
Commodore in a day.  First, #include <functions.h>.  Second, and most
problematical is to cast all parameters to system routines as long.

Manx --> Lattice

I'm afraid that I haven't had to port from Manx to Lattice, so I can't
say much about this except that it should be much easier than porting from
Lattice to Manx with 16 bits, because there will be no need to fiddle with
all of those casts to longs when doing function calls.


By the way, all of my code assumes that ints are at least 16 bits (no need
to ever run on one of those 8 bit machines again :-).  If I need a specific
length, I use 'byte', 'word', or 'longword' rather than int.  Also, I attempt
to isolate all system calls in a module or two so that changing these later
is much easier.  That ESPECIALLY means memory allocation and deallocation
routines!

	Happy porting!
	Gary