sizeof()在编译时或运行时计算 [英] sizeof() calculated at compile time or run time

查看:421
本文介绍了sizeof()在编译时或运行时计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于sizeof关键字的问题


sizeof关键字在编译时或运行时计算大小吗?


- 已发布在 news://freenews.netfront.net 上 - 投诉 ne ** @ netfront.net -

gotta question on sizeof keyword

does the sizeof keyword calcuates the size at compile time or run time ??

-- Posted on news://freenews.netfront.net - Complaints to ne**@netfront.net --

推荐答案

CodeMonk3y写道:
CodeMonk3y wrote:

有关sizeof关键字的问题


sizeof关键字在编译时或运行时计算大小吗?
gotta question on sizeof keyword

does the sizeof keyword calcuates the size at compile time or run time ??



编译时。

At compile time.


Rolf Magnus写道:
Rolf Magnus wrote:

CodeMonk3y写道:
CodeMonk3y wrote:

有关sizeof关键字的问题
gotta question on sizeof keyword



对于OP,sizeof是一个运算符。

For the OP, sizeof is an operator.


sizeof关键字在编译时计算大小或运行

时间?
does the sizeof keyword calcuates the size at compile time or run
time ??



在编译时。


At compile time.



我没有跟上标准的变化。是否添加了

可变长度数组(目前在C99中)?这是一个案例

其中sizeof是一个运行时构造,因为在编译时不能确定这样一个数组的大小



C ++中没有真正需要的东西,有std :: vector等等。


Brian


-

如果电视是保姆,互联网是一个醉酒的图书管理员,他们不会闭嘴。

- Dorothy Gambrell( http://catandgirl.com


Alf P. Steinbach写道:
Alf P. Steinbach wrote:

*默认用户:
* Default User:


我没有跟上标准的变化。

是否添加了可变长度数组(目前在C99中)?
I haven''t been keeping up with the changes coming to the standard.
Are variable-length arrays (currently in C99) being added?



No.


No.



我认为不太可能。

I thought it unlikely.


那是一个案例

其中sizeof是一个运行时构造,就像这样一个数组的大小

在汇编时无法确定。
That''s one case
where sizeof is a run-time construct, as the size of such an array
can''t be determined at compilation.



在C99中可能是这样,但是如果在C ++中添加了可变长度数组

支持,那么在C ++中就不会这样了。


It might be so in C99, but presumably if variable length array
support was added in C++ it would not be so in C++.



呃,什么?你怎么会有这样的C99风格的VLA,可以在

编译时调整大小?

Er, what? How would you have C99-style VLAs that could be sized at
compilation?


>
>



C ++中没有真正需要的东西,使用std :: vector和all。
It''s not something really needed in
C++, with std::vector and all.



目前的做法另有说法。一些编译器支持例如

_alloca,以不安全的方式执行可变长度数组支持

可以简单安全地完成。


Current practice says otherwise. Several compilers support e.g.
_alloca, to do in an unsafe way what variable length array support
could do simply and safely.



他们是专门为C ++支持的,还是从C

扩展中保留?


Brian


-

如果电视是保姆,那么互联网就是醉酒的图书管理员,他们赢得了b $ b闭嘴。

- Dorothy Gambrell( http://catandgirl.com


这篇关于sizeof()在编译时或运行时计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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