[comp.sys.amiga.tech] tip for compiling AmigaDos I/O on Un*x

koren@hpfelg.HP.COM (Steve Koren) (08/02/90)

This might be of interest to folks trying to compile programs
written with AmigaDos I/O (Read(), etc) on a Un*x or DOS machine.

Try making a bunch of #defines, such as:

#ifndef AMIGA
#   include <stdio.h>
#   define BPTR FILE *
#   define Close(x) fclose(x)
#   define Open(x,y)  fopen(x,y)
#   define Read(x,y,z) read(fileno(x),y,z)
#   define Write(x,y,z) write(fileno(x),y,z)
#   define MODE_OLDFILE "r"
#   define MODE_NEWFILE "w"
#   define Input()  stdin
#   define Output() stdout
#   define Printf printf
#endif

I've had pretty good luck getting stuff to compile under Un*x that
way.  You can do the reverse as well, as long as you remember which
Un*x stdio calls not to use.  Have to remember that MODE_NEWFILE is
not really the same as "w", etc, as well.  Works for ARP stuff too,
such as the Printf->printf above.

   - steve

peter@sugar.hackercorp.com (Peter da Silva) (08/05/90)

In article <13920084@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes:
> #   define BPTR FILE *

Try "typedef FILE *BPTR" instead, so you won't be burned by "BPTR ifh, ofh".
-- 
Peter da Silva.   `-_-'
<peter@sugar.hackercorp.com>.