Questions tagged [cstdint]

Header that declares types and macro constants to deal with fixed-width cross-platform integer types, available since C++11. This header replaces stdint.h wich is tagged as deprecated.

30 questions
101
votes
3 answers

vs

What is the difference between stdint.h and cstdint? Both of them are available in MSVC (Visual Studio 2010) and gcc-4.5.1. Also both define the intX_t/uintX_t types (where X is the size in bytes of the type). If the rationale in both headers is…
PaperBirdMaster
  • 11,602
  • 9
  • 41
  • 84
94
votes
3 answers

long long int vs. long int vs. int64_t in C++

I experienced some odd behavior while using C++ type traits and have narrowed my problem down to this quirky little problem for which I will give a ton of explanation since I do not want to leave anything open for misinterpretation. Say you have a…
Travis Gockel
  • 24,743
  • 10
  • 80
  • 105
81
votes
9 answers

'uint32_t' does not name a type

I'm trying to compile a C++ software package that was written in 2007 and I'm getting this error: error: ‘uint32_t’ does not name a type This is happening in 64-bit Ubuntu using g++ 4.5.2. It compiles fine on 64-bit CentOS using g++ 4.1.2. Is there…
rmtheis
  • 6,978
  • 9
  • 56
  • 74
41
votes
6 answers

Should I use cstdint?

I have been pondering on whether or not I should use the typedefs inside or not. I personally prefer writing uint32_t over unsigned int and int8_t over char etc... since it to me is alot more intuitive. What do you guys think? Is it a good…
ronag
  • 43,567
  • 23
  • 113
  • 204
26
votes
2 answers

How to check if fixed width integers are defined

In C++, fixed width integers are defined as optional, but I can't seems to find the recommended way to check if they are actually defined. What would be a portable way to check if fixed width integers are available?
Rick de Water
  • 2,016
  • 1
  • 13
  • 29
8
votes
2 answers

Why don't we have in C++?

Why doesn't C++ have header for floats like it has for integers? EDIT : By I mean header that provides typedefs for float and double. Much like qreal typedef in Qt. Hope my question is clear now.
missingfaktor
  • 86,952
  • 56
  • 271
  • 360
6
votes
1 answer

C++11 uint types vs u_int

I just stumbled upon the type u_int8_t because it did not compile in Windows+MinGW (but compiled fine under Linux). According to this site the C++11 standard defines the type uint8_t. I just used the latter and everything worked. The questions that…
masgo
  • 410
  • 3
  • 14
5
votes
2 answers

Does the standard guarantee that uint8_t, int8_t, and char are all unique types?

It seems the following is guaranteed to pass (asked already here): #include static_assert(!std::is_same_v); static_assert(!std::is_same_v); To quote cppreference [char] has the same…
Eric
  • 87,154
  • 48
  • 211
  • 332
5
votes
4 answers

Boost's "cstdint" Usage

Boost's C99 stdint implementation is awfully handy. One thing bugs me, though. They dump all of their typedefs into the boost namespace. This leaves me with three choices when using this facility: Use "using namespace boost" Use "using…
patt0h
  • 53
  • 1
  • 4
3
votes
1 answer

Visual Studio 2015 C-header-related issue while trying to compile DOSBox SVN Daum in Windows 10

I'm having header-related issues apparently new to VS2015 while trying to compile DOSBox SVN Daum in Windows 10. Examples: Severity Code Description Project File Line Suppression State Error (active) the global scope has no…
3
votes
1 answer

(C++11) g++ not providing a proper warning if cstdint types are used 'incorrectly'

Today i was trying some types defined in the cstdint header file: std::uint16_t, std::uint_least16_t and so on.. I think they are very useful because you know exactly or at least how big they are, unlike the more common platform-specific ones: int,…
Gaudo
  • 73
  • 1
  • 4
2
votes
1 answer

What is a good example of leveraging the differences between int*_t, int_fast*_t and int_least*_t in C++11?

According to online documentation, there are differences in between these fixed width integer types. For int*_t we fixed the width to whatever the value of * is. Yet for the other two types, the adjectives fastest and smallest are used in the…
Eduardo
  • 619
  • 5
  • 23
2
votes
1 answer

Cstdint Missing Error When Installing Pydaedalus with PiP

I am working on an application which involves route finding (a completely different subject), but for testing I need example mazes to test on. A colleague suggested I use pydaedalus to generate large scale mazes in the format I need. I am using the…
Ambluj
  • 23
  • 5
2
votes
5 answers

How to output unsigned/signed char or types as integers with << in C++

Background: I have template stream operators (e.g. operator << (ostream &, std::vector )) (that output container elements that may possibly be of some 8-bit integer type, (e.g. unsigned char, int_least8_t, et cetera). Problem: Default is that…
StellarVortex
  • 577
  • 4
  • 19
2
votes
3 answers

How are standard integers from translated during compilation?

In C, it is common (or at least possible) to target different processor architectures with the same source code. It is also common that the processor architectures define integer sizes differently. To increase code portability and avoid integer size…
Izzo
  • 3,366
  • 10
  • 29
  • 57
1
2