Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #71078
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: uint32_t is not the same as long unsigned int ? |
| Date | 2020-01-03 23:18 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <qup3ng$krp$1@dont-email.me> (permalink) |
| References | <qup223$eje$1@dont-email.me> |
On 1/3/20 10:50 PM, wolfgang bauer wrote:
> Hi
>
> 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}'
>
>
> So the compiler states: uint32_t is unsigned int.
> I thought, uint16_t is unsigned int.
>
>
> I thought, "int" is 16 Bit. And so "long int" should be 32 Bit.
>
> Am i wrong with that ?
Yes. char, signed char, and unsigned char must have at least 8 bits.
short, unsigned short, int, and unsigned int must have at least 16 bits.
long and unsigned long must have at least 32 bits.
long long and unsigned long long must have at least 64 bits.
However, any of those types can have more than the minimum number of
bits. The exact sized typedefs from <cstdint> are optional, but if
supported, must have exactly the specified number of bits - so you
should not make assumptions about which standard types they are typedefs
for.
The actual requirements are in terms of the required range of values
that each standard integer type must be able to represent, and are
incorporated by reference from the C standard. I've converted those
ranges into bit counts to better match your question.
> If it is important for the answer: I'm working here with Linux 64-Bit, CodeLite / gcc.
One a 64-bit machine, long is often a 64-bit type, with int being a 32
bit type.
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