Both belongs to the C standard library
You don't have to link anything to use it
What did you expect? Why is that surprising to you?
"Size of C types like int, short, long are platform-dependent"
But stdint types are not. uint8_t is literally 8 bits without sign same with int16_t, uint24_t or int32_t, naming someones
And these .h files are platform-dependent too
I know. I'm saying if shot, int, long are platform-dependent type how can a combination of them make a non-platform dependent type?
Because the .h file is different for each platform
let me check it, i'm writing without proofing
So on platforms where int is 4 bytes, int32_t can use it, on platforms where int isn't 4 bytes, int32_t must use something else
yep, checked and wrong from my part: The definitions in <stdint.h> put requirements on the types it names, so int16_t must have a width of exactly 16, and INT16_MAX must be 32767. Butthere are no equivalent requirements on types such as int24_t or int128_t. So it is possible for int24_t to be a 16 bit type, or int_least128_t to be a 64 bit type. This is not in the interests of either the implementer or the user of an implementation. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n851.htm
Well at least there's no u3 / i17 etc
Explain this platform dependency. What exactly do you mean by that? Is it related to OS? ARCH? 32bit or 64bit? What are those platforms that make exceptions?
Wdym by arch? arm/x86_64/powerpc or 32bit/64bit?
macOS has a different size for long than windows / linux I think
I mean all of those things
Byte didn't always mean 8bits, so some platforms used different widths when referring to bytes, but nowadays it is more or less normalized that byte means 8bits
One more detail - these are minimally guaranteed sizes of each datatype. The maximum is another thing
Обсуждают сегодня