Mail Archives: djgpp/1997/08/19/18:38:46
Eli Zaretskii wrote:
>
> On Sun, 17 Aug 1997, *** Brett *** wrote:
>
> > > Is there a function or keyword which can determine the size of an actual
> > > function from a reference to it? I've tried sizeof(), but it returns the
> > > size of the reference instead of the actual function.
> > >
> >
> > The way to do it is to declare a "null" function directly after the one you
> > want the size of, and then subtract the two pointers (I think). I _do_ know
> > that I saw this in the FAQ - it related to locking code in protected
> > mode.
>
> A word of caution is in order. If you use this technique, please be
> aware that you cannot be always sure that it will work. Subtle
> changes in compiler optimizations in some future release could
> rearrange functions and break this trick altogether.
And it will probably give you rubbish if the compiler
decides to inline a function. BTW, is there a keyword
to keep the compiler to do this on its own? Just
the opposite of ``inline'' ?
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -