delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/04/10:37:45

From: Brian Osman <osmanb AT rpi DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: quick malloc question
Date: Mon, 03 Mar 1997 10:30:22 -0500
Organization: Rensselaer Polytechnic Institute, Troy NY, USA
Lines: 21
Message-ID: <331AEE8E.6AD5@rpi.edu>
References: <B0000041587 AT datasoft DOT datasoft DOT com DOT br> <5fdn2o$mvl AT freenet-news DOT carleton DOT ca>
Reply-To: osmanb AT rpi DOT edu
NNTP-Posting-Host: darkwing.stu.rpi.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Paul Derbyshire wrote:
>
> Why the HELL do people keep writing things like (char *)malloc(x)????????
> 
> GCC, and to my knowledge other compilers, allow any pointer to be assigned
> to a variable of type void * and conversely allow any variable of type void
> * to be assigned to any pointer, without casts.
> 
> --
>     .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
>  -()  <  When I go to the theater, I always go straight to the "bag and mix"
>     `*'  bulk candy section...because variety is the spice of life... [me]
> Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

If you don't, and compile with -Wall (which everyone should) then you
get warnings about conversion without a cast. I know it happens with gcc
on
other platforms, and I think it happens on DOS too. (It still works, but
I don't like having warnings...)

Brian

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019