Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.lang.c Subject: Re: Arcane C hacks? Message-ID: <6449@utzoo.UUCP> Date: Sat, 1-Mar-86 23:50:37 EST Article-I.D.: utzoo.6449 Posted: Sat Mar 1 23:50:37 1986 Date-Received: Sat, 1-Mar-86 23:50:37 EST References: <1700003@umn-cs.UUCP>, <1700004@umn-cs.UUCP> Organization: U of Toronto Zoology Lines: 30 > 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