问题描述
关于sizeof关键字的问题
sizeof关键字在编译时或运行时计算大小吗?
- 已发布在上 - 投诉 -
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 --
推荐答案
编译时。
At compile time.
对于OP,sizeof是一个运算符。
For the OP, sizeof is an operator.
在编译时。
At compile time.
我没有跟上标准的变化。是否添加了
可变长度数组(目前在C99中)?这是一个案例
其中sizeof是一个运行时构造,因为在编译时不能确定这样一个数组的大小
。
C ++中没有真正需要的东西,有std :: vector等等。
Brian
-
如果电视是保姆,互联网是一个醉酒的图书管理员,他们不会闭嘴。
- Dorothy Gambrell()
No.
No.
我认为不太可能。
I thought it unlikely.
在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?
目前的做法另有说法。一些编译器支持例如
_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()
这篇关于sizeof()在编译时或运行时计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!