Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Suggested method for returning a string from a C program? Date: Thu, 20 Mar 2025 12:28:27 -0700 Organization: None to speak of Lines: 47 Message-ID: <87r02rsdr8.fsf@nosuchdomain.example.com> References: <868qp1ra5f.fsf@linuxsc.com> <20250319115550.0000676f@yahoo.com> <20250319201903.00005452@yahoo.com> <86r02roqdq.fsf@linuxsc.com> <20250320165914.000030eb@yahoo.com> <20250320172922.00002a08@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 20 Mar 2025 20:28:28 +0100 (CET) Injection-Info: dont-email.me; posting-host="2f20008cbcfa55ae60494be276e0bfaa"; logging-data="4043012"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/F1Y8w2SuLi1sIblK4jz2R" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:T+3hIDBWbRUQTIZsoav5Yl3UlDg= sha1:kMGEaYmy365hnB5RYtfQjQatJcU= Bytes: 2842 Michael S writes: > On Thu, 20 Mar 2025 15:16:05 -0000 (UTC) > Muttley@DastardlyHQ.org wrote: >> On Thu, 20 Mar 2025 16:59:14 +0200 >> Michael S wibbled: >> >On Thu, 20 Mar 2025 14:50:25 -0000 (UTC) >> >Muttley@DastardlyHQ.org wrote: >> > >> >> >> >> What makes you think they're macros? >> >> >> > >> >PRIu64 and PRId64 are macros. They are ugly. >> >> Never even heard of them. Looking them up I can't see much use for >> them frankly except if you're starting out on an unknown system and >> can't find out the info any other way which would be ... odd. > > Then how exactly do you printf value of type int64_t in a code that > expected to pass [gcc] compilation with no warnings on two platforms, > one of which is 64-bit Unix/Linux and another is just about anything > else? #include #include int main(void) { int64_t n = 42; printf("%ju\n", (intmax_t)n); } The alternative is: #include #include #include int main(void) { int64_t n = 42; printf("%" PRId64 "\n", n); } I was able to write the first from memory. I had to consult the standard for the second, though I'm sure I'd be able to remember it if I used it more often. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */