2 ms·
Downvoters, my question was wether int8_t* and char* are interchangeable. I can't see why that's a bad question to ask. Given "char* buf", there might well be a
by jstimpfle 8y ago
Downvoters, my question was wether int8_t* and char* are interchangeable. I can't see why that's a bad question to ask. Given "char* buf", there might well be a difference between "(uint8_t) buf[1]" and "((uint8_t* )buf)[1]".
Now, upon further researching it looks like uint8_t always has size 1 (as does char), but I'm still not positive that the second expression is technically valid.
- topspin 8y ago> my question was whether int8_t* and char* are interchangeable They are not. Not every "C" compiler complies with whatever standard you care to cite. There are DSP platforms[1], for instance, where char is 16 bits. Obviously any hypothetical pointer arithmetic on such a platform must differ between (u)int8_t and char. The intent of (u)int8_t is that such a platform will either a.) correctly implement (u)int_8 and operate on exactly 8 bits as intended or b.) fail to compile. This is demonstrably different than assuming char is 8 bits and yet compiling when it is not. [1] for sale here: https://www.digikey.com/en/product-highlight/t/texas-instruments/c2000 https://www.digikey.com/en/product-highlight/t/texas-instrum...