Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #71102
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: uint32_t is not the same as long unsigned int ? |
| Date | 2020-01-04 02:16 -0800 |
| Organization | None to speak of |
| Message-ID | <87ftgvo7b7.fsf@nosuchdomain.example.com> (permalink) |
| References | <qup223$eje$1@dont-email.me> <slrnr10jmm.9in.grahn+nntp@frailea.sa.invalid> |
Jorgen Grahn <grahn+nntp@snipabacken.se> 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 <cinttypes>,
> 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 */
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
uint32_t is not the same as long unsigned int ? wolfgang bauer <schutz@gmx.de> - 2020-01-04 04:50 +0100
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-03 23:18 -0500
Re: uint32_t is not the same as long unsigned int ? wolfgang bauer <schutz@gmx.de> - 2020-01-04 05:36 +0100
Re: uint32_t is not the same as long unsigned int ? Robert Wessel <robertwessel2@yahoo.com> - 2020-01-04 00:19 -0600
Re: uint32_t is not the same as long unsigned int ? Barry Schwarz <schwarzb@delq.com> - 2020-01-03 22:29 -0800
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-03 23:56 -0800
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-04 09:48 -0500
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-04 14:48 -0800
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-04 21:39 -0500
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-04 19:43 -0800
Re: uint32_t is not the same as long unsigned int ? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-01-05 06:09 +0100
Re: uint32_t is not the same as long unsigned int ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-05 20:50 -0500
Re: uint32_t is not the same as long unsigned int ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-04 08:37 +0000
Re: uint32_t is not the same as long unsigned int ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-04 02:16 -0800
Thank you. (was:Re: uint32_t is not the same as long unsigned int ?) wolfgang bauer <schutz@gmx.de> - 2020-01-04 15:15 +0100
csiph-web