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 cbmvax.cbmvax.cbm.UUCP Path: utzoo!watmath!clyde!cbosgd!ukma!psuvm.bitnet!psuvax1!burdvax!bpa!cbmvax!higgin From: higgin@cbmvax.UUCP Newsgroups: net.micro.amiga Subject: Re: Pointers and AllocMem with Aztec Message-ID: <398@cbmvax.cbmvax.cbm.UUCP> Date: Thu, 12-Jun-86 14:40:27 EDT Article-I.D.: cbmvax.398 Posted: Thu Jun 12 14:40:27 1986 Date-Received: Tue, 17-Jun-86 05:41:49 EDT References: <1868@gitpyr.UUCP> Reply-To: higgin@cbmvax.UUCP (Paul Higginbottom) Organization: Commodore Technology, West Chester, PA Lines: 52 In article <1868@gitpyr.UUCP> lbg@gitpyr.UUCP (Lee B Grey) writes: > >I have spent all day trying to get AllocMem to work with my Aztec >compiler. I refuse to break down and use 32-bit integers. So >what am I supposed to do?? I have tried the code in the RKM, >which does not work. I have tried declaring AllocMem() as: > extern APTR long APTR > extern APTR * long * APTR * > struct APTR * char void > struct APTR char * void * >None of them work. They all return a NULL pointer! BTW, I am not >as dumb as this looks. I knew that void would not work. But take a >look at Aztec's list of Amiga functions AND at the functions.h file >in the include directory -- they both list AllocMem as a void of all >things!! > >Bottom line: If anyone can tell me how to AllocMem a structure (I am >trying for FileInfoBlock), without using the 32-bit compiler option and >32-bit linker library, PLEASE let me know! Please reply through mail, as >I am too busy banging my head against the wall to read news with any >regularity. > >Thanks, dudes and dudettes! > >Lee Well Lee, I hope you get this on the net, I sypathize with you - but I had no trouble, and am one ecstatically happy Aztec C user, and I NEVER use the 32 bit option. The trick you're probably missing is not casting sizeof( to a long, because AllocMem() and ALL NON-AZTEC FUNCTIONS expect LONGS for all numeric parameters. The following fragment will work, guaranteed. #include #include extern void *AllocMem(); struct FileInfoBlock *GetAFib() { return(AllocMem((long)sizeof(struct FileInfoBlock), MEMF_PUBLIC)); } The void * declaration of AllocMem is convenient because Aztec C doesn't complain about equating pointers to voids to any other type without a cast. (This is in the manual). Regards, Paul Higginbottom Disclaimer: I do not work for Commodore and my opinions are at least my own.