jump to navigation

c-faq review and a chinese translation (1.2) January 19, 2007

Posted by TSAI HONG-BIN in Programming.

please refer to http://c-faq.com/decl/exactsizes.html

1.2 Why aren’t the sizes of the standard types precisely defined?

Though C is considered relatively low-level as high-level languages go, it does take the position that the exact size of an object (i.e. in bits) is an implementation detail. (The only place where C lets you specify a size in bits is in bit-fields within structures; see questions 2.25 and 2.26.) Most programs do not need precise control over these sizes; many programs that do try to achieve this control would be better off if they didn’t.

Type int is supposed to represent a machine’s natural word size. It’s the right type to use for most integer variables; see question 1.1 for other guidelines. See also questions 12.42 and 20.5.


雖然和其他高階語言比起來, C 被認為是相對的低階語言,在它的設計概念上,物件的確切大小 (以位元計) 是屬於實作的細節。( C 唯一允許你以位元為單位指定大小的地方,是資料結構裡的 bit-fields ) 大多數的程式不需要精準的大小控制,而且,許多嘗試控制資料型態大小的程式,如果不去控制反而比較好。

int 型態被認為是機器的 word size (按:指的應該是 register word 吧?)。對於大多整數變數而言,那是正確的型態。



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: