This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sizeof(function) functionality


On Monday 7 July 2003 7:49 pm, Alexandre Oliva wrote:
> > 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.

That's why I said "or something like it".

> 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 :-)

Well, the same mechanism that resolves references might be able to resolve 
function sizes too, if the linker is built to handle this. Just a thought :)

Ben


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]