Usage of INT_MAX, etc.

Thiago Macieira thiago at kde.org
Wed Oct 25 21:11:53 BST 2006


Jaroslaw Staniek wrote:
>Because INT_MAX tells you nothing about # of bits when you read the
> code. Even if someone knows the standard, # of bits is >= 32. You 
> mentioned it is == 32 on KDE-supported targets, so I added the example
> about long integers.

Exactly. 'int' is supposed to be the size of the machine word, according 
to the ISO C spec, but it's no longer being respected on 64-bit 
architectures (the word is 64 bits in size). In theory, 'int' is supposed 
to be the fastest storage type one can use.

>(**) I am worried that 2147483647L tells nothing in the header file (or
> at least you need to think two seconds about its meaning).

Then call it POWER_2_31 or something. I fail to see why it's got to be 
connected to a type. The value of 2^31-1 won't change any time soon in 
the universe. Though giving it a name that means "the maximum value that 
a 32-bit signed integer can hold" makes sense...

Also note that qint32 and qint64 could be larger than their sizes promise 
(like ISO C 99's int32_t and int64_t), but this will probably never 
happen in a platform we support.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20061025/07188a6c/attachment.sig>


More information about the kde-core-devel mailing list