delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/13/22:55:34

Date: Wed, 13 Sep 95 20:03 MDT
From: mat AT ardi DOT com (Mat Hostetter)
To: empty AT sans DOT vuw DOT ac DOT nz (Malcolm Taylor)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: interrupt stops being invoked
Newsgroups: comp.os.msdos.djgpp
References: <199509120623 DOT QAA22743 AT tinny DOT eis DOT net DOT au> <DEsyFI DOT FC3 AT jade DOT mv DOT net> <437gve$2iv AT st-james DOT comp DOT vuw DOT ac DOT nz>

>>>>> "Malcolm" == Malcolm Taylor <empty AT sans DOT vuw DOT ac DOT nz> writes:

    Malcolm> It will work, casting a function pointer is allowed (just
    Malcolm> another type of pointer, nothing special).

In most C implementations, yes.  But my understanding is that some C
implementations can make function pointers be more complicated types
which cannot be cast to simple pointers; for example, a "function
pointer" might also include information about argument types.
Consequently, the language spec allows certain types of casts to be
forbidden.  From Harbison & Steele:

	ANSI C introduces the type void * as a "generic pointer."  It
	has the same representation as type char * for compatibility
	with older implementations, but the language treats it
	differently.  Generic pointers cannot be dereferenced with the
	* or subscripting operators.  Any pointer to an object or
	incomplete type (but _not_ to a function type) can be
	converted to type void * and back without change.

	[emphasis in original]

I was just making a technical point about one of the many ways my hack
isn't ANSI compliant.

    Maclolm> There are a few other things to watch for.  Make sure you
    Malcolm> do not compile with optimizations (esp. not -O3) as these
    Malcolm> can shift code about.

To the best of my knowledge, gcc won't shift them about unless those
functions are static.  Obviously it's allowed to do so, but I don't
think it does.  But since some future gcc implementation might, an
"assert" is probably a good idea.

-Mat

- Raw text -


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