sizeof()的工作原理是什么? [英] How sizeof() works?

查看:604
本文介绍了sizeof()的工作原理是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道sizeof()的工作原理吗?它是在运行时还是在编译时计算

对象的大小?


谢谢,

Madhura

Hi All,
I want to know how sizeof() works? Whether it calculates size of the
object at run time or at compile time?

Thanks,
Madhura

推荐答案

ma **** ******@rediffmail.com 说:
大家好,
我想知道sizeof()是如何工作的?它是在运行时还是在编译时计算
对象的大小?
Hi All,
I want to know how sizeof() works? Whether it calculates size of the
object at run time or at compile time?




在编译时。唯一的例外情况发生在符合C99的编译器上(其中很少见,但显然至少存在一些)

,其中涉及可变长度数组。 />

-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)



At compile time. The only exception occurs in C99-conforming compilers
(precious few of those, but apparently there are at least some around)
where variable-length arrays are concerned.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


但它如何计算对象的大小。我的意思是如果我们使用sizeof()计算一个

用户定义的类对象的大小,它是如何知道

关于类结构的?

But how it calculates the size of object. I mean how it came to know
about a class structure if we use sizeof() to calculate the size of an
user definied class object?




" Richard Heathfield" <在***** @ invalid.invalid>在消息中写道

news:dq ********** @ nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com ...

"Richard Heathfield" <in*****@invalid.invalid> wrote in message
news:dq**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
ma**********@rediffmail.com 说:
大家好,
我想知道sizeof()是如何工作的?它是在运行时还是在编译时计算
对象的大小?
Hi All,
I want to know how sizeof() works? Whether it calculates size of the
object at run time or at compile time?



在编译时。唯一的例外发生在符合C99的编译器中(其中很少见,但显然至少存在一些)
其中涉及可变长度数组。



At compile time. The only exception occurs in C99-conforming compilers
(precious few of those, but apparently there are at least some around)
where variable-length arrays are concerned.




gcc到了那里......

http://gcc.gnu.org/gcc-4.1/c99status.html


这篇关于sizeof()的工作原理是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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