[comp.sys.amiga] Function Typing in Lattice 3.10 was Re: AmigaDos DeleteFile

mph@rover.UUCP (07/31/87)

In article <43STEVEG@MAINE> JRH4373@TAMVENUS.BITNET writes:
>return.  Why then, does lattice issue a 'pointers to different objects'
>warning when I declare a variable lock as 'struct FileLock *' and then
>use it like this:  'lock = CreateDir()'?  Is FileLock the right name?
>Do I have to declare CreatDir() as an extern and specify it's type or what?
>     
>Joel << Hatchet >> Hall
>jrh4373@tamvenus
>     
I use Lattice 3.10 extensively and am generally pleased.  I also use Amiga-Lint
from Gimpel (get version 2.00h - the original b version has a deadly pre-
processor bug that generates a lot of extraneous error messages).  I have dealt
a great deal with typing problems (a hopeless Pascal Junkie), and think I can
recommend a fix.

Since CreateDir is undeclared, it is assumed to return type int, which is
definitely not type struct FileLock * (which, if memory serves, is the correct
type).  What I have done is go through the Dos, Exec, etc header files and
create correct function prototypes declared as external.  Then when I include
the header, the relevant function prototypes are also used.  Some functions
don't seem to have a logical header file, so I've also created a top-level
include such as doslib.h, which declares the Meager Dog interfaces.  While it
is some work, both Lint and Lattice have been satisfied by this approach.  Also,
there are far fewer wierd and wonderful bugs in the code after Lint gets done.

An alternative would be to write 'lock = (struct FileLock *) CreateDir(dirname)'
but you have to do that every time!

Mark Huth - I speak for myself
seismo!noao!mcdsun!nud!rover!mph

peter@sugar.UUCP (Peter da Silva) (08/05/87)

A LOCK is a BPTR: a BCPL ptr to (in this case) a (struct FileLock). This is
what you should do if you want at the innards of a LOCK:

typedef BPTR LOCK;

#define BTOA(x) ((x)<<2)

	LOCK dirlock;
	struct FileLock *dirptr;

	dirlock = CreateDir(...);
	dirptr = (struct FileLock *)BTOA(dirlock);

In any case CreateDir is not (struct FileLock *).
-- 
-- Peter da Silva `-_-' ...!seismo!soma!uhnix1!sugar!peter (I said, NO PHOTOS!)