Path: utzoo!attcan!uunet!samsung!usc!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!tut!ra!rosenber From: rosenber@ra.abo.fi (Robin Rosenberg INF) Newsgroups: comp.sys.amiga.tech Subject: Re: malloc under Lattice C V5.05 Message-ID: Date: 13 Aug 90 14:42:42 GMT References: <3034@orbit.cts.com> Sender: rosenber@ra.abo.fi Organization: Abo Akademi University, Finland Lines: 35 In-reply-to: ceej@pawl.rpi.edu's message of 12 Aug 90 17:58:45 GMT >bga@pnet51.orb.mn.org (Bruce Albrecht) writes: >>I had defined the following fragment: >> char *outname; >> outname = malloc(SomeConstant); >>the compiler gave me a warning that the malloc was not the same type as >>outname, and I had to change it to (char *) malloc to get rid of the warning. >>Am I misunderstanding something, or is the errata sheet wrong, or is there >>something wrong with Lattice C (either in the include or compiler)? There is a small bug in one of the lattice include files where malloc and a few other functions have the wrong type, i.e char* instead of void*. It is either stdio.h or stdlib.h. Trying to include both of these files will give you an extern item attribute mismatch. Fix the file that is wrong. >Here's a (sort of) related question: does it even matter if it gives you >a warning like this? Most cases when I get these warnings (type mismatch) >are either my own dumb fault, which usually will crash if left in the >code, or unimportant or outright intentional type mismatching (ie, >automatic type conversions for code efficiency). These programs have always >seemed to work right, even when I was given the warning (well, assuming it/ >they were the ONLY warnings/errors, of course); am I missing something? >Is my code less effcient or corrupt or something if I leave these? Warnings should not be ignored. They are there to help you find bugs in your programs. You should check all warnings to see if it is a possible bug and if it is still correct rewrite it so the compiler gives you no more warnings. Type mismatches can be corrected with an explicit cast. Other warnings are more serious, like 'argument count incorrect', which is usually fatal. With Lattice C you can tell the compiler to issue an error message instead of a warning for certain warnings. ------------ Robin Rosenberg