Arcane C hacks?

Henry Spencer henry at utzoo.UUCP
Sun Mar 2 14:50:37 AEST 1986


> 2)  Is there a machine independent way to coerce non-pointer-
>     to-function values to pointer-to-function values?

No, because on some machines they are very different animals:  a pointer
to a function is not necessarily a pointer to the bytes comprising its
code.  Some machines want a rather more elaborate structure, in which a
pointer to a function is a module identifier and a function-within-module
identifier, and there is extra information somewhere that allows the
machine to interpret this.  Which leads to...

> ...Further, many machines (for instance, the VAX)
> insist on particular prologues and epilogues for procedures
> which I have no interest in and do not wish to generate
> code for.

If you want to treat something as a function, you *must* observe the
conventions that your machine (and your compiler) want to see.  There
is no portable way around this.  In fact, there's no entirely portable
way to do what you want at all, because the basic nature of the conventions
(never mind the details of them!) is machine-dependent.  For example,
machines that use a module+function form of function pointer will need
some sort of module dictionary somewhere, which you're going to have to
build.  Some machines won't let you do what you want at all, in fact,
because on them, code is code and data is data and never the twain shall
meet.  (Examples:  a pdp11 running split-space; a segmented machine that
makes a distinction between code and data segments.)
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list