Skip to main content
Filter by
Sorted by
Tagged with
4 votes
2 answers
389 views

I want to portably work with 64-bit signed types in C. However - I know that int64_t is not guaranteed to be defined. I can use some preprocessor magic in my build system generation (e.g. CMake's ...
einpoklum's user avatar
  • 137k
1 vote
3 answers
123 views

I was wondering, what is the difference between int_least32_t and long, since according to the standard, long has to be at least 32 bits wide and int_least32_t should, according to the standard, also ...
luksev's user avatar
  • 33
0 votes
2 answers
157 views

Consider the following program: #include <stdio.h> #include <stdint.h> int main() { uint16_t result; uint16_t ui = 1; int16_t si = -1; result = si * ui; ...
ilja's user avatar
  • 163
0 votes
3 answers
194 views

Looking at the code: #include <stdio.h> #include <stdint.h> int main() { char foo[512]={}; printf("%d", *((uint32_t*)foo)); return 0; } I'm having hard time ...
Broman3100's user avatar
0 votes
2 answers
146 views

I read that stdint.h is used for portability, but I'm confused. If I wrote a program on a 32-bit system, uint32_t (unsigned int) is 4-bytes. But when this program is run on 16-bit system, int is ...
porpomas's user avatar
0 votes
0 answers
235 views

The header file <stdint.h> usually provides typedefs and macro constants for integers of 8, 16, 32 and 64 bit width. The standard also allows any N-bit type to be specified by using identifiers ...
saxbophone's user avatar
2 votes
3 answers
234 views

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 = ...
xiver77's user avatar
  • 2,332
1 vote
2 answers
415 views

Using stdint.h from glibc (gcc SUSE Linux version 9.2.1, Intel Core I7 processor) I came across a most strange behaviour when printing INT32_MIN directly: #include <stdio.h> #include <stdint....
Arc's user avatar
  • 462
2 votes
1 answer
94 views

Is it possible to determine at compile time whether an implementation provides exact-width integer types? Sample code (wanted): #include <stdint.h> #if HAS_EXACT_WIDTH_INTEGER_TYPES uint32_t ...
pmor's user avatar
  • 6,757
3 votes
1 answer
3k views

Is it OK to initialize a uint8_t array from a string literal? Does it work as expected or does it mangle some bytes due to signed-unsigned conversion? (I want it to just stuff the literal's bits in ...
jdm's user avatar
  • 10.3k
0 votes
2 answers
234 views

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'...
Beginner's user avatar
-1 votes
1 answer
885 views

I am trying to construct a module for python in C. The module has several lines and methods, but one of the most important is to pass, efficiently, the integer representation of the concatenation of a ...
Juan's user avatar
  • 2,113
4 votes
3 answers
1k views

stdatomic.h appears to contain atomic_uint_least16_t and atomic_uint_fast16_t, which are _Atomic versions of the stdint.h types uint_least16_t and uint_fast16_t, but it does not contain ...
Jason S's user avatar
  • 191k
3 votes
1 answer
360 views

I'd like to be able to portably fprintf() a uint_fast32_t as defined in stdint.h with all leading zeroes. For instance if my platform defined uint_fast32_t as a 64-bit unsigned integer, I would want ...
Willis Hershey's user avatar
7 votes
3 answers
5k views

I'm having trouble understanding how does comparing two ints, where one is unsigned int32 and the other one signed int32 work. Let's consider this simple program: #include <stdint.h> int main(...
MLapaj's user avatar
  • 401
3 votes
1 answer
21k views

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 ...
Mohamed Hossam's user avatar
1 vote
1 answer
322 views

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 ...
Gabriel Vasconcelos's user avatar
0 votes
1 answer
318 views

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 ...
Ryan's user avatar
  • 112
0 votes
1 answer
46 views

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 $ ...
psychoslave's user avatar
  • 3,131
0 votes
2 answers
55 views

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, ...
Pinja's user avatar
  • 33
-1 votes
1 answer
335 views

I looked inside the header file <stdint.h> on my implementation. I see the following: typedef long int int_fast16_t; typedef long int int_fast32_t; typedef long int int_fast64_t; I have a 64-...
Galaxy's user avatar
  • 2,531
3 votes
1 answer
3k views

I'm just wondering why things like uintptr_t are in stdint.h, but other types like size_t are in stddef.h? Is there logic behind these headers?
Evan Carroll's user avatar
0 votes
3 answers
690 views

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: ...
nowox's user avatar
  • 29.7k
0 votes
1 answer
4k views

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 ...
Oliver Strong's user avatar
4 votes
1 answer
1k views

I'm working on a small networking application that uses byte arrays. Traditionally these would be declared with something like char buf[] = .... This seems to be how it is (still?) done in most ...
gmolau's user avatar
  • 3,024