www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/03/11:30:04

Message-ID: <c=GB%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-970303161728Z-11@crianlarich.Indigo>
From: Robert Humphris <r DOT humphris AT indigo-avs DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>,
"'Eyal Ben-David'"
<eyalb AT aks DOT com>
Subject: RE: quick malloc question
Date: Mon, 3 Mar 1997 16:17:28 -0000
Encoding: 22 TEXT

>`malloc' returns void* while p can be of any pointer type. You are actually
>casting from  (void*) to (char*).
>
>In C it is not a problem, the compiler does the conversion for you with or
>without warnings (depends on the compiler and warning level).
>
>In C++ it is a compilation error so you must explicitly cast from one
>pointer type to another (except when the target type is void*).

What you say is true, but in C++ we are meant to use new to dynamically
allocate memory space, in C
I believe it to be better practice to always cast your pointers esp. if
you use the likes of lint to ensure that
your code is extra safe

Rob Humphris
>
>
>Eyal. 
>
>

- Raw text -


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