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
0
votes
2 answers

Searching elements in an array

I want to search the index of the element in array days[] of uint8_t type which has next-to-next elements of 0x2 and 0x3 using a variable of type uint16_t and print the index value of the element '0x2'. I have assigned 'uint16_t search = 0x23' but I…
Beginner
  • 73
  • 3
0
votes
2 answers

Predeclaration of C stdint types

When I tried to declare some types defined in stdint.h a conflict with /usr/include/bits/stdint-uintn.h:24:19 predeclaration occurs typedef struct __uint8_t uint8_t; Error message: /usr/include/bits/stdint-uintn.h:24:19: error: conflicting types…
0
votes
1 answer

Can't convert a uint64_t to a double properly. What am I missing?

To give some background, I'm coding the JVM for Java 8 in C, and I'm trying to print the Double value located in the Constant Pool. I have two variables uint32_t that represent the high and low value of a double. I'm trying to print this double but…
0
votes
1 answer

Is it possible for int_least16_t to be an alias for int rather than short?

From the C99 standard, I can see that int_least16_t is guaranteed to have a width of at least 16 bits. 7.18.1.2 Minimum-width integer types ... The typedef name uint_leastN_t designates an unsigned integer type with a width of at least N , such…
Ryan
  • 112
  • 1
  • 6
0
votes
2 answers

Maximum size of object macro

I tried to write the following: #include #include void *ptr = malloc(SIZE_MAX); But the compiler gave me the following warning: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
0
votes
1 answer

How to configure Fedora 29 to use ruby 'number-theory' gem?

So basically RubyNumberTheory require the NArray gem, and it seems it requires some native compilation tools and probably some additional configuration. So on a Fedora 29, here is what was tried $ gem install narray Building native extensions. This…
psychoslave
  • 2,783
  • 3
  • 27
  • 44
0
votes
2 answers

Base and inherited objects to wrap stdint variables in C++

I am refactoring some C++ code for an AVR project that uses Sloeber (Arduino plugin for Eclipse). The project has many "settings" variables that are stored in EEPROM, have upper and lower limits, require string labels, etc. These settings are of…
Pinja
  • 33
  • 1
  • 4
0
votes
3 answers

Explaining this passage in "About size_t and ptrdiff_t"

In this blog entry by Andrey Karpov entitled, "About size_t and ptrdiff_t" he concludes with As the reader can see, using ptrdiff_t and size_t types gives some advantages for 64-bit programs. However, it is not an all-out solution for replacement…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
0 answers

SDL with g++: stdint.h: No such file or directiory

I'm trying to get SDL working using g++ on Windows 10, and I'm getting an error which states that stdint.h could not be found. g++ -g -Wall -I includes/SDLm/x86_64-w64-mingw32/include main.cpp -o main In file included from…
0
votes
3 answers

In embedded MCU application is it better to use uint_fast16_t or size_t in for loops?

I would like to write portable code for applications that will run on different MCUs (16-bits, 32-bits or 64-bits base). MSP-430 nRF52 (32-bits) PIC (16-bits) C51 (8-bits) Let's consider this snippet: events = 0; for (size_t i = 0; i <…
nowox
  • 25,978
  • 39
  • 143
  • 293
0
votes
1 answer

AARCH64 gcc #include fails

I am trying to compile some kernel code for a raspberry pi 3 from a x86 computer using the aarch64 cross compiler in one of my source files I require stdint.h however when I try to compile it fails saying >make rm kernel8.elf *.o >/dev/null…
Oliver Strong
  • 415
  • 1
  • 7
  • 15
0
votes
1 answer

Storing int16_t's in uint64_t's

So I've got 4 uint16_t's, and I am trying to store them in a single uint64_t. I think I have that working. uint64_t encode(int16_t A, int16_t B, int16_t C, int16_t D){ return (uint64_t)((uint16_t) A) << 48 | (uint64_t)((uint16_t) B) <<…
AndrewGrant
  • 786
  • 7
  • 17
0
votes
4 answers

Why do fixed width types delegate back to primitives?

In Visual Studio 14 the stdint.h header has definitions for fixed width integer types, but if you actually look at there definitions they just delegate back to primitives. The definitons are as follows: typedef signed char int8_t; typedef…
vandench
  • 1,973
  • 3
  • 19
  • 28
0
votes
0 answers

Back to a 2013 project, I have a lot of "type u_int32_t could not be resolved"

I compiled my project in 2013 with g++ v. 4.7.3 under Gentoo Linux and Eclipse Indigo with c++11. In this project, I need integer size perfectly defined. So, I used u_int32_t, u_int8_t types. Today, I have g++ v. 4.9.2 under Debian Jessie, still…
lalebarde
  • 1,684
  • 1
  • 21
  • 36
0
votes
2 answers

Left-shifting an uint64_t zeroes out most significant dword

The title sums it up: left-shifting an uint64_t doesn't output the expected value, and I'd like to know why. What I get is the expected result with its 4 most significant bytes zeroed out. I'm using an x86_64 CPU (Intel i7 3770k), on Debian Jessie…
pr0gma
  • 577
  • 3
  • 8
  • 18