Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!sdcsvax!sdchem!tps From: tps@sdchem.UUCP (Tom Stockfisch) Newsgroups: comp.lang.c Subject: Re: Size of a function Message-ID: <609@sdchema.sdchem.UUCP> Date: Sun, 4-Jan-87 02:30:25 EST Article-I.D.: sdchema.609 Posted: Sun Jan 4 02:30:25 1987 Date-Received: Sun, 4-Jan-87 06:36:45 EST References: <2100@brl-adm.ARPA> Sender: news@sdchem.UUCP Reply-To: tps@sdchemf.UUCP (Tom Stockfisch) Organization: UC San Diego Lines: 25 In article <2100@brl-adm.ARPA> LINNDR%VUENGVAX.BITNET@wiscvm.wisc.edu writes: > To the best of my knowledge, there is no way currently defined in >C to get the size of a function, in any units. My immediate interest is >in telling what function an address belongs during run-time. The only >solutions I know of involve an intimate knowledge of the relocatable file >(esp. the symtab) format. Is there a good way to determine this value? > >It might be nice if sizeof(function_name) could be defined to return this >value. The trouble is that any such scheme will not be implementable on a machine with a segmented architecture. On such a machine, different functions might not belong to the same address space, and thus pointers into each of them could not be meaningfully compared. If you have gotten an address that points somewhere in the *middle* of a function then you must have gotten it outside the confines of C (you can't apply "++" to a function pointer). You have no hope of doing this portably. If you want to know to which function you belong, and you are *not* on a segmented machine, why don't you just keep an ordered list of function addresses and find where your mystery address fits in the list? || Tom Stockfisch, UCSD Chemistry tps%chem@sdcsvax.UCSD