Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Don't be fooled by cpp.sh Date: Mon, 16 Dec 2019 22:29:57 -0800 Organization: None to speak of Lines: 32 Message-ID: <87sgljv50a.fsf@nosuchdomain.example.com> References: <70391932-ccbc-4bc7-b693-881ab06eb6d3@googlegroups.com> <356f42b0-2919-4e72-a1a2-3813212973f1@googlegroups.com> <7f5255fa-f634-4dc7-9f33-409acc47356c@googlegroups.com> <2a6b4b2d-283f-4b5f-9f4c-025efaa087a8@googlegroups.com> <87v9qgvw28.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="f43f53019f1947236be6bf564cb59bdd"; logging-data="9188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YQlLi9EQ5pSJkBbBfRWU5" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:XlmC9ZpNymUcurk/K3d4JtKXdzw= sha1:84wvVCqEH9ibsNVKIBuYA5uCN+E= Xref: csiph.com comp.lang.c++:70534 Ben Bacarisse writes: [...] > intmax_t is useful, in part because it solves the printf problem. You > can portably print any integer i using > > printf("%ld\n", (intmax_t)i); You mean "%jd\n". > whether i is an extended type like __int128 or even some weird 99-bit > integer type. To be completely sure, you need to use either intmax_t or uintmax_t depending on whether the argument is signed or unsigned. If you have a name for the type, you can do something like big_type i = some_value; if ((big_type)-1 > (big_type)0) { printf("%ju\n", (uintmax_t)i); } else { printf("%jd\n", (intmax_t)i); } But quite often you'll know from context whether the type is signed or unsigned, even if you don't know which type it is. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com [Note updated email address] Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */