difference in stdint.h and inttypes.h

B

Bill Cunningham

What's the main difference in inttypes.h and stdint.h ? I usually use
the latter if I'm looking for uint32_t. Does inttypes.h bring in more int
functions or what?

Bill
 
B

Bill Cunningham

Tim said:
Bill Cunningham said:
What's the main difference in inttypes.h and stdint.h? [snip]

I assume you mean "What's the main difference between inttypes.h
and stdint.h?".
Does inttypes.h bring in more int functions
Yes.

or what?

That too.

Here is a link for a reference:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

The contents of <inttypes.h> are specified in section 7.8,
and <stdint.h> in 7.20.

Ok what's the difference in this standard and n1256 that I have?

B
 
B

Bill Cunningham

Bill said:
Tim said:
Bill Cunningham said:
What's the main difference in inttypes.h and stdint.h? [snip]

I assume you mean "What's the main difference between inttypes.h
and stdint.h?".
Does inttypes.h bring in more int functions
Yes.

or what?

That too.

Here is a link for a reference:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

The contents of <inttypes.h> are specified in section 7.8,
and <stdint.h> in 7.20.

Ok what's the difference in this standard and n1256 that I have?

B

And I see where it mentions intmaxdiv_t in n1256. I'm not quite sure
what the inttypes.h types and functions are about so maybe stdint.h is what
I might want to work with because I do use uint32_t and have never used
inttypes.h.

B
 
N

Nobody

And I see where it mentions intmaxdiv_t in n1256. I'm not quite sure
what the inttypes.h types and functions are about so maybe stdint.h is what
I might want to work with because I do use uint32_t and have never used
inttypes.h.

7.8 Format conversion of integer types <inttypes.h>

[#1] The header <inttypes.h> includes the header <stdint.h>
and extends it with additional facilities provided by hosted
implementations.

<stdint.h> defines the types. <inttypes.h> defines the PRI* and SCN*
macros for use with *printf() and *scanf() as well as a handful of
functions for parsing intmax_t and uintmax_t values, specifically:

strtoimax strtoumax wcstoimax wcstoumax

These are analogous to strtol() etc, but for (u)intmax_t rather than for
(unsigned) long.

IOW, you only need <inttypes.h> if you need to reliably[1] convert the
types defined in <stdint.h> to/from textual representation.

[1] Using *printf/*scanf with <stdint.h> types *without* using the
PRI*/SCN* macros isn't reliable. E.g. printf("%d", (int32_t) x) will only
work if "int" is 32-bit, which isn't necessarily true.
 
T

Tim Rentsch

Bill Cunningham said:
Tim said:
Bill Cunningham said:
What's the main difference in inttypes.h and stdint.h? [snip]

I assume you mean "What's the main difference between inttypes.h
and stdint.h?".
Does inttypes.h bring in more int functions
Yes.

or what?

That too.

Here is a link for a reference:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

The contents of <inttypes.h> are specified in section 7.8,
and <stdint.h> in 7.20.

Ok what's the difference in this standard and n1256 that I have?

As you now have access to both documents, there is
an obvious simple method to discover that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top