🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #5397

Re: malloc under Lattice C V5.05

#5397
From: Brian Zupke
Date: Sun, 23 Sep 1990 06:19
33 lines
1812 bytes
In article <V%$%LR_@rpi.edu> ceej@pawl.rpi.edu (Chris J Hillery) writes:
>bga@pnet51.orb.mn.org (Bruce Albrecht) writes:
>
>>I had defined the following fragment:
>>  char *outname;
>> 
>>  outname = malloc(SomeConstant);
>
>> [discussion of malloc deleted]

In this case, the pointer mismatch can be eliminated by "casting" the 
malloc function to type char.  For example:

char *outname;

outname = (char *)malloc(SomeConstant);


>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)
> [some stuff deleted]
>Is my code less effcient or corrupt or something if I leave these?

Howdy.  My understanding is that type mismatches can make code less portable.
Even though your programs work fine with these warnings, other compilers
(having different size variables) may not.  It is always best to explicitly
state your intentions by use of type casting (see above).  Also, if you simply
ignore these warnings, then it different (possibly more serious) warnings can
be "lost in the shuffle".  And, of course, when using Manx C, they'll make an
ERROR message scroll right off the screen.

-Brian
Test signature file.
Technical Details
Message-ID: <1990Sep23.061925.6887@jato.jpl.nasa.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!jato!mars!zupke
References: <3034@orbit.cts.com> <V%$%LR_@rpi.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.amiga.tech
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!jato!mars!zupke
From: zupke@mars.jpl.nasa.gov (Brian Zupke)
Subject: Re: malloc under Lattice C V5.05
Message-ID: <1990Sep23.061925.6887@jato.jpl.nasa.gov>
Sender: news@jato.jpl.nasa.gov
Nntp-Posting-Host: mars.jpl.nasa.gov
Reply-To: zupke@mars.UUCP (Brian Zupke)
Organization: Jet Propulsion Laboratory, Pasadena, CA.
References: <3034@orbit.cts.com> <V%$%LR_@rpi.edu>
Date: Sun, 23 Sep 90 06:19:25 GMT