Yo Greg! On Tue, 18 Nov 2025 19:19:09 -0500 Greg Troxel <[email protected]> wrote:
> Hal Murray <[email protected]> writes: > > We could make a macro to make it less ugly. Since we haven't done > > that yet, it probably isn't that much of a problem. > > The standard approach is: > > Use %d for int, %ld for long. That is way over simplifying the problems. One real problem is (long long) and (unsigned long long). We must use those for paratable 64-bit values. Ints may be only −32767, +32767. Longs may be only −2147483647, +2147483647 But we often need 64 bits −9223372036854775807, +9223372036854775807. It is easy to think that is a rare case, but you need them for types like size_t and ssize_t which are often compared to integers in loops, etc. If the loop vaiable is not as big as size_t or ssize_t then we get tons of "potential integer overflow" warnings. > Use PRI macros for other types. > > But, the real issue surely is that we have a lot of system-defined > types that are underlying int/long, and this varies by CPU type. > However, it also varies by OS, because more or less always POSIX > requires that things be an integral type. We tried PRI types. It was a disaster. PRI types are in C99, but only the newest C compilers get them right. And, IMHO, they are hard to read. RGDS GARY --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703 [email protected] Tel:+1 541 382 8588 Veritas liberabit vos. -- Quid est veritas? "If you can't measure it, you can't improve it." - Lord Kelvin
pgp2Lh3mjqyp_.pgp
Description: OpenPGP digital signature
