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: uint32_t is not the same as long unsigned int ? Date: Sat, 04 Jan 2020 02:16:28 -0800 Organization: None to speak of Lines: 37 Message-ID: <87ftgvo7b7.fsf@nosuchdomain.example.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="ae6c07825fe602dea7ed53b20475ec70"; logging-data="11934"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gLYd3TxABshXYCo0cGPZB" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:PRxN1ko1vUCrLruZfXcv2WkQYgc= sha1:Ert6IPG9SmDIw8w179DH/hU2N98= Xref: csiph.com comp.lang.c++:71102 Jorgen Grahn writes: > On Sat, 2020-01-04, wolfgang bauer wrote: >> A Question about Datatypes: >> >> >> uint32_t x; >> >> printf("%lu\n", x); >> >> That results in this warning: >> >> warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type >> 'uint32_t {aka unsigned int}' > > Others have already explained the larger picture, but concretely: > > If you insist on combining std::printf and the fixed-width integer > types, you need to use the PRI... macros from , > particularly: > > #define PRIu32 "u" *OR* you can convert to a type that you know is wide enough and that printf handles directly: uint32_t x; std::printf("x = %lu\n", (unsigned long)x); Or, of course: std::cout << "x = " << x << "\n"; -- 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 */