Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: printf and time_t Date: Thu, 05 Feb 2026 11:22:24 -0800 Organization: None to speak of Lines: 59 Message-ID: <87pl6j807j.fsf@example.invalid> References: <10jfol6$2u6r8$1@news.xmission.com> <20260106200522.000015ea@yahoo.com> <87h5sy2rlb.fsf@example.invalid> <87qzs1gliq.fsf@example.invalid> <20260108012620.000041a9@yahoo.com> <87bjj5gei4.fsf@example.invalid> <20260108023846.0000260c@yahoo.com> <10jpi8h$15aea$1@dont-email.me> <20260109141859.00004f22@yahoo.com> <10jv3rb$15aea$2@dont-email.me> <20260111132015.000026ad@yahoo.com> <86zf6kkjw0.fsf@linuxsc.com> <20260111235104.00001463@yahoo.com> <86ms1pj0bc.fsf@linuxsc.com> <10ltjjt$1o4pk$1@dont-email.me> <865x8cio5y.fsf@linuxsc.com> <10lvt1s$2fu8f$1@dont-email.me> <878qd89iyl.fsf@example.invalid> <10m0m3b$2ngak$2@dont-email.me> <10m208p$35jde$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 05 Feb 2026 19:22:26 +0000 (UTC) Injection-Info: dont-email.me; posting-host="d063e519f8c8ebf42097b88d5c7b8b46"; logging-data="3628530"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+i8OQDNJat0RoFE0vZB7jp" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:Pmn8aI5JbB/FEZhf15plN20bc0s= sha1:nbyHkzfAjH9AarzE+C81VrACnko= Xref: csiph.com comp.lang.c:396611 David Brown writes: > On 05/02/2026 00:52, Bart wrote: >> On 04/02/2026 23:39, Keith Thompson wrote: >>> Bart writes: >>> [...] >>>> The problem is that C expects an exact format-code when trying to use >>>> *printf functions, and for that you need to know the exact types of >>>> the expressions being passed. For example: >>>> >>>>    uintptr_t x;                    // from above examples >>>>    double y;                       // >>>>    printf("x * y is %?", x * y);   // What's '?' >>> >>> Since you asked... >>> >>> '?' is 'f' (or 'g' or 'e', or 'a', or any of those in upper case). >>> `x * y` is of type double. >> >> The 'from above examples' applies to both x and y. That means that >> 'double' /may/ have been redefined like this (from my post): >> >>   #ifdef SQLITE_OMIT_FLOATING_POINT >>   # define double sqlite3_int64 >>   #endif >> >> I don't know what 'sqlite3_int64' is, but it sounds like a signed >> integer. I was asked to give examples of conditional types, and >> thought it best to do so from actual programs. > > What you have found is an idiocy in SQLITE, not a problem in the C > language or printf. If the macro "SQLITE_OMIT_FLOATING_POINT" is > defined, then the type named "sqlite3_int64" is not an integer type, > nor can it hold arbitrary 64-bit integers (as Michael S pointed out, > and I assume accurately, it can hold 53 bit integers). I do not know > what this type is used for in the code, but something like > "sqlite3_bignum" would be a far better choice of name. And if it is > intended that people print out these values directly, defining > "PRsqlite3_bignum" to "%g" or "%llu" as appropriate would be helpful. > (Yes, the resulting printf statements would be ugly - better ugly and > correct than wrong). The macro doesn't define "sqlite3_int64", which as far as I can tell is always an integer type. It redefines "double". That macro in isolation does seem deeply silly, but I haven't worked on sqlite3's source code. Apparently the authors found it convenient. Presumably anyone working on the source code has to keep in mind that the word "double" doesn't necessarily mean what it normally means. It's not the way I would have written it. I probably would have defined a type name that can be either "double" or "sqlite3_int64", depending on the setting of SQLITE_OMIT_FLOATING_POINT. But I don't know enough about the sqlite3 source code to be able to meaningfully criticize it. In almost all contexts, it's perfectly reasonable to assume that the word "double" in C code refers to the predefined floating-point type. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */