Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: net.micro.amiga Subject: Problems with compiling using 16-bit ints (MANX C) Message-ID: <8605102156.AA03379@cory> Date: Sat, 10-May-86 17:56:55 EDT Article-I.D.: cory.8605102156.AA03379 Posted: Sat May 10 17:56:55 1986 Date-Received: Tue, 13-May-86 00:38:42 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: University of California at Berkeley Lines: 40 The most common problem is really not the compiler's fault. Many of you all assume integers are the same size as pointers, and do things like: win = (struct Window *)OpenWindow() ... This is incorrect. If the compiler uses 16-bit integers, and since OpenWindow() returns an integer, you will loose the MSB word of the returned value when it is converted to a pointer. The proper way to do the call is: extern struct Window *OpenWindow(); win = OpenWindow(); If the library or system call can return different types of pointers, then you should still extern it to SOME type of pointer: extern char *OpenLibrary(); struct GfxBase GfxBase; struct MathBase MathBase; GfxBase = (struct GfxBase *)OpenLibrary( ...) MathBase= (struct MathBase *)OpenLibrary( ...) If you will never use the returned pointer (but still must set it for the library routines to use), then it would suffice to just declare everything as char *: extern char *OpenLibrary(); char *GfxBase, *MathBase; GfxBase = OpenLibrary( ...) MathBase= OpenLibrary( ...) -Matt