Questions tagged [stdint]

stdint.h is a header file in the C standard library to allow programmers to write more portable code.

stdint.h introduced in the C99 standard library section 7.18 and it provides a set of typedefs that specify exact-width integer types, together with the defined minimum and maximum allowable values for each type, using macros.

This header is particularly useful for embedded programming which often involves considerable manipulation of hardware specific I/O registers requiring integer data of fixed widths, specific locations and exact alignments.

Read more

118 questions
2
votes
1 answer

Are the integer types included in the stdint.h library "extended integer types"?

im learning about integer conversion rank but i have a question, i often use the stdint.h library, and for what im reading about "integer conversion rank" it says: "The rank of any standard integer type shall be greater than the rank of any extended…
Cblue X
  • 143
  • 6
2
votes
3 answers

What is the difference between using INTXX_C macros and performing type cast to literals?

For example this code is broken (I've just fixed it in actual code..). uint64_t a = 1 << 60 It can be fixed as, uint64_t a = (uint64_t)1 << 60 but then this passed my brain. uint64_t a = UINT64_C(1) << 60 I know that UINT64_C(1) is a macro that…
xiver77
  • 2,162
  • 1
  • 2
  • 12
2
votes
1 answer

Is it possible to determine at compile time whether an implementation provides exact-width integer types?

Is it possible to determine at compile time whether an implementation provides exact-width integer types? Sample code (wanted): #include #if HAS_EXACT_WIDTH_INTEGER_TYPES uint32_t i; #else /* handle the case */ #endif Reason of the…
pmor
  • 5,392
  • 4
  • 17
  • 36
2
votes
1 answer

namespace over a #include header file question

I porting code from a windows machine to a Mac. I am using OS X 10.6 with Xcode 3.2.5 I have a header file called api.h which has the following code: namespace ocip { #include "onan/ocip/ocip.h" } ocip.h includes #include stdint.h which has…
Michael Wildermuth
  • 5,762
  • 3
  • 29
  • 48
2
votes
1 answer

INT_FAST16_MAX does not reflect type size in MSVC 2010?

C99 defines int_fast16_t as an "integer types being usually fastest having at least the specified width", and Microsoft define it as a 32-bit integer in MSVC 2010: typedef char int_fast8_t; typedef int int_fast16_t; typedef int…
Steve-o
  • 12,678
  • 2
  • 41
  • 60
2
votes
1 answer

Defining global constants in C

How can I define a global constant in C? I was told to do some thing like this in header.h const u32 g_my_const; in code.c #include "header.h" const u32 g_my_const= 10U; But I get a compilation error: error: uninitialized const 'g_my_const'…
Mohamed Hossam
  • 33
  • 1
  • 1
  • 4
2
votes
1 answer

Where is stdlib.h / stdint.h in Visual Studio 2010?

I was googling a bit and heard that although stdint.h was not shipped with old versions of Visual Studio, it should be there in Visual Studio 2010. However, I have this project that's supposed to use it, but it says it can't find either stdlib.h or…
slhck
  • 36,575
  • 28
  • 148
  • 201
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
  • 4,461
  • 13
  • 45
  • 82
2
votes
3 answers

Problems installing RMagick-gem in Rails

I've been plowing through tutorials all day trying to install RMagick, and have gotten pretty far now I reckon, but have stumbled apon an error that I really don't know how to solve, nor get any useful info on. When I try to install the gem, I get…
Soroush Hakami
  • 5,226
  • 15
  • 66
  • 99
2
votes
2 answers

Usage of uintptr_t vs DWORD_PTR

Both are used for storing addresses and doing pointer arithmetic, both are defined in WinAPI, when should I use a uintptr_t (cstdint) vs a DWORD_PTR (Windows.h)? Both are 32bits and 64bits in x86 and x86_64 respectively A DWORD_PTR is an unsigned…
otc
  • 431
  • 4
  • 15
2
votes
2 answers

Get twice as wide type

basically, i'd like to (at compile time) get the twice-as-wide type from a stdint type. I can do it by hand like this template class twice_as_wide{}; template<> class twice_as_wide { public: typedef uint16_t…
IdeaHat
  • 7,641
  • 1
  • 22
  • 53
2
votes
2 answers

stdint.h for Java?

Is there a java library implementing the standard data types as they are available in C? In Java everything is signed, so using byte to store uint8_t comes with some problems, for example: byte test = (byte) 0xf3; System.out.println("test = " +…
Ethan Leroy
  • 15,804
  • 9
  • 41
  • 63
2
votes
1 answer

How to load the largest integer possible in one memory operation?

I'm building a small bytecode VM that will run on a variety of platforms including exotic embedded and microcontroller environments. Each opcode in my VM can be variable length(no more than 4 bytes, no less than 1 byte). In interpreting the…
Earlz
  • 62,085
  • 98
  • 303
  • 499
2
votes
3 answers

Equivalent of u_int16_t from windows stdint.h in gnu?

So far I'm assuming that u_int16_t is a windows type somewhere inside of an MSVS header file called stdint.h. I'm using GNU g++ for a compiler (actually codeblocks with mingw) and I wondered if typedef unsigned short uint_least16_t; (inside…
pandoragami
  • 5,387
  • 15
  • 68
  • 116
1
vote
2 answers

bit fields vs. stdint definitions

So I am programming in C++, and as far as I can tell there is no C++ equivalent to stdint.h. Which is no problem, seeing as you can just grab a copy of stdint and include it... but my question is basically this, what is the difference between these…
Dave
  • 723
  • 7
  • 19