www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/09/04:29:24

Date: Tue, 9 Apr 1996 11:21:49 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Jethro Wright <Jetman AT gnn DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: A Proper Cast for a Funtion Ptr....
In-Reply-To: <199604090345.XAA27177@mail-e2b-service.gnn.com>
Message-Id: <Pine.SUN.3.91.960409111845.24867Y-100000@is>
Mime-Version: 1.0

On Mon, 8 Apr 1996, Jethro Wright wrote:

> >But beware: when a C compiler sees this, it actually generates code to
> >call `newfn' with a calling sequence that is appropriate for `oldfn'.  In
> >this case, it converts `s' from int to unsigned int, but other subtle
> >things might be going on there too.  This is what casting function
> >pointers means.  It's best to avoid it, unless you can't do otherwise.
> 
> 	Eli, it has always been my understanding that casts in
> C *don't* do conversions (at least, for casts bet integral types),

This is NOT true for casting functions.  When you call a casted function, 
the stack and the variables it gets are set up according to the cast.  
Otherwise, casting function would have no effect at all, except escaping 
the compiler type-checks (which is not what it is meant to do).

- Raw text -


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