delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/19/12:15:41

Newsgroups: comp.os.msdos.djgpp
From: Elliott Oti <oti AT phys DOT uu DOT nl>
Subject: Re: passing arg 1 of 'free' ....
Sender: usenet AT fys DOT ruu DOT nl (News system Tijgertje)
Message-ID: <Pine.OSF.3.95.980619164139.5179G-100000@ruunf0.phys.uu.nl>
In-Reply-To: <358A5A9F.E57B1F07@pac.nl>
Date: Fri, 19 Jun 1998 14:50:00 GMT
References: <358A5A9F DOT E57B1F07 AT pac DOT nl>
Mime-Version: 1.0
Organization: Physics and Astronomy, University of Utrecht, The Netherlands
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Fri, 19 Jun 1998, Theo Landgraf wrote:

> i get this warning:
> 
> passing arg 1 of 'free' discards 'const' from pointer target type.
> 
> what does this mean?
> how can i solve it?


It means you are trying to delete (i.e. alter)  a pointer
after informing the compiler that you are going to do no such thing by
declaring the pointer as const.

const char *myptr; // means I am not going to alter myptr => myptr = const

free(myptr); // means please release the memory pointed to by myptr
             // and make myptr = NULL;

If you are going to alter myptr don't declare it as const char *, just as
char *.

Cheers,

  Elliott Oti
  kamer 104, tel (030-253) 2516 (RvG)    
  http://www.fys.ruu.nl/~oti


- Raw text -


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