Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fixed width integer types

23 views
Skip to first unread message

Paul

unread,
Sep 14, 2018, 3:45:50 PM9/14/18
to
Could someone possibly explain to me the relationship between
fixed width integer types and the std namespace?

On my compiler, if I #include <cstdint> then
std::int8_t yy = 65; works fine but also
int8_t z = 65; also works.

(And yes, it gives 'A').
Does int8_t belong to the std namespace or not?
How can this designation be optional?

Thanks for your help.

Paul

bitrex

unread,
Sep 14, 2018, 5:36:11 PM9/14/18
to
Well what is ur compiler? ???

IDK

Paul

unread,
Sep 14, 2018, 6:49:15 PM9/14/18
to
> Co>
>
> Well what is ur compiler? ???


Code Blocks with C++11 enabled.

Paul

Alf P. Steinbach

unread,
Sep 14, 2018, 7:10:08 PM9/14/18
to
On 14.09.2018 21:45, Paul wrote:
> Could someone possibly explain to me the relationship between
> fixed width integer types and the std namespace?
>
> On my compiler, if I #include <cstdint> then
> std::int8_t yy = 65; works fine but also
> int8_t z = 65; also works.
>
> (And yes, it gives 'A').
> Does int8_t belong to the std namespace or not?

It Came From Outer Space.

Or, well, C99.


> How can this designation be optional?

<cstdint> guarantees to provide it in namespace `std`, and may also
provide it in the global namespace.

<stdint.h> guarantees to provide in the global namespace, and may also
provide it in the `std` namespace.

A header wrapper such as ¹<stdlib/c/stdint.hpp> that includes both
headers, guarantees that the name is in both the global namespace and
the `std` namespace. Guaranteed behavior is IMHO preferable. But if you
don't want to use such a wrapper, then including <stdint.h> is the more
practical choice: <cstdint> just adds complication, for historical
idealistic (or what I believe to be idealistic) reasons, and effectively
reduces portability, since non-qualified use of the name may compile
with the compiler used for original development, and not with others.

Cheers & hth.,

- Alf

Notes:
¹ <url:
https://github.com/alf-p-steinbach/Wrapped-stdlib/tree/master/source/c>

Chris M. Thomasson

unread,
Sep 14, 2018, 10:47:34 PM9/14/18
to
What compiler is Code Blocks using? I am guessing GCC right?

Paul

unread,
Sep 15, 2018, 6:27:33 AM9/15/18
to
Yes, good point for clarity. Code Blocks is an IDE, not a compiler.
GCC is the compiler.
Thanks also to Alf Steinbach for excellent analysis, and thanks to
bitrex, too.

Paul
0 new messages