sizeof(function) functionality
Alexandre Oliva
aoliva@redhat.com
Mon Jul 7 18:49:00 GMT 2003
On Jul 7, 2003, Ben Davis <bndavis@ntlworld.com> wrote:
> Allegro <http://alleg.sf.net/> has used the following technique for
> a long time:
I guess they never tried -ffunction-sections, or this option is a
do-nothing on ports in which they actually care about a function's
size.
> Assuming it doesn't exist already, I think sizeof(function) or something like
> it would be a very useful GNU Extension for future GCC versions :)
Can't really be done, at least not without surprising semantics.
IIRC, sizeof already has a well-defined meaning when the argument is a
function: the function decays to pointer, and you get the size of the
pointer. Besides, sizeof is supposed to return a compile-time
constant, but the size of a function is most often only known at
assembly time, or, worse, at link time, in case linker relaxations are
available. And don't even get me started on ELF dynamic library
symbol binding and replacement rules :-)
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer
More information about the Gcc-help
mailing list