www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/08/23:52:53

Message-Id: <199604090345.XAA27177@mail-e2b-service.gnn.com>
Mime-Version: 1.0
Date: Mon, 08 Apr 1996 23:50:35
From: Jethro Wright <Jetman AT gnn DOT com>
To: djgpp AT delorie DOT com
Subject: Re: A Proper Cast for a Funtion Ptr....

>	(void (*)(int, void *, void *))newfn

	Thanx to all who responded privately and publicly concerning
this tidbit....

>
>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),
instead they're a "promise" to the compiler that the user knows that
the underlying variables are conpatible.  So, the compiler *shudn't*
generate any conversion code in this case.  Logically, the compiler
shudn't even convert a "coerced" assignment bet a float and an integral
type, since the cast implies that the user (programmer) knows that the
contents of the two storage spaces are compatible.

	Having said that, I'll just make sure w/ a simple test pgm, just
to see what really happens....


=======================================================================
 The continued survival of the human race, despite its own stupidity,
 is the strongest argument for the existence of a benevolent God.
=======================================================================


- Raw text -


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