Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C word size and standard size

in this article, taken from the book "Linux kernel development": http://www.makelinux.net/books/lkd2/ch19lev1sec2
it says:

The size of the C long type is guaranteed to be the machine's word size. On the downside, however, code cannot assume that the standard C types have any specific size. Furthermore, there is no guarantee that an int is the same size as a long

Question is, i thought int is the same as the word size, not long, and i couldn't find any official standard which defines this saying.

any thoughts?

like image 931
Yarel Avatar asked Dec 13 '22 03:12

Yarel


1 Answers

Sometimes, people on the Internet are wrong. The sizes are fixed by the ABI. Linux ports don't necessarily create an original ABI (usually another platform or manufacturer recommendation is followed), so there's nobody making guarantees about int and long. The term "machine word" is also very ill-defined.

like image 174
Potatoswatter Avatar answered Dec 25 '22 21:12

Potatoswatter