功能的大小 [英] size of a function

查看:45
本文介绍了功能的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

找到一个函数的大小是否有意义???

类似sizeof(main)???

感谢你

ranjan。

does it make sense to find the size of a function ???
something like sizeof(main) ???
thanking you
ranjan.

推荐答案

maadhuu写道:
maadhuu wrote:
找到一个大小是否有意义功能???
类似sizeof(主要)???
感谢你
ranjan。
does it make sense to find the size of a function ???
something like sizeof(main) ???
thanking you
ranjan.




不,这样做是约束违规。


Robert Gamble



No, doing so is a constraint violation.

Robert Gamble


文章< f6 ******** **********************@localhost.talkab outprogramming.com> ;,

maadhuu< ma ******* *****@yahoo.com>写道:
In article <f6******************************@localhost.talkab outprogramming.com>,
maadhuu <ma************@yahoo.com> wrote:
找到一个函数的大小是否有意义???
像sizeof(main)???
does it make sense to find the size of a function ???
something like sizeof(main) ???




No.


gcc没有--pedantic允许它,但它返回的大小是1

(至少在我的测试用例中)。使用--pedantic,或者如果我使用更严格的编译器,它会在编译时抱怨。


记住,你没有任何东西 - 执行一个函数

指针,除了存储它或通过它调用(或将它转换为

到void *)。如果你能以某种方式对函数对象进行索引,那么函数的大小可能是有意义的,但是你不能使用
(并非没有调用未定义的行为。)


如果您有希望使用程序来检查

a函数的代码,或者打击函数或诸如此类的东西,那么你可以忘记那个
在标准C中 - 没有可移植的方式来实现这一点

[并且任何非便携方式都是特定于您的操作系统的新闻组的主题。 ]

-

任何足够先进的错误都与功能无法区分。

- Rich Kulawiec



No.

gcc without --pedantic allows it, but the size it returns is 1
(at least for my test cases). With --pedantic, or if I
use a stricter compiler, it complains at compile time.

Remember, there isn''t anything you can -do- to a function
pointer, except to store it or call through it (or convert it
to void*). sizeof a function might make sense if you could
index the function object in some way, but you cannot
(not without invoking undefined behaviour.)

If you had hope of using a program to examine the code of
a function, or bash the function or whatnot, then you can
forget about that in standard C -- there''s no portable way to do that
[and any non-portable way is a topic for a newsgroup specific to
your operating system.]
--
Any sufficiently advanced bug is indistinguishable from a feature.
-- Rich Kulawiec


maadhuu在04/09/05写道:
maadhuu wrote on 04/09/05 :
找到一个函数的大小是否有意义???


Nope。

类似sizeof(主要)???
does it make sense to find the size of a function ???
Nope.
something like sizeof(main) ???




为什么你需要这些信息吗?


-

Emmanuel

C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

C库: http:// www。 dinkumware.com/refxc.html


"它是指定的。但任何编写这样代码的人都应该将这些代码转化为蚯蚓并喂给鸭子。 - Chris Dollin CLC



Why do you need this information ?

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"It''s specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC


这篇关于功能的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆