4 ms·
In writing performance critical cross platform embedded code, I have found that exact width integer types are less useful than the "minimum width" style types y
by TheNewAndy 6y ago
In writing performance critical cross platform embedded code, I have found that exact width integer types are less useful than the "minimum width" style types you get from plain C (e.g. you can't write cross platform code with an 8-bit exact width integer type, because there is no such type on some platforms). It is disappointing to see this language provides no such types.
- cesaref 6y agoWell since C99 there is an exact width C type for 8 bit ints, so i'm assuming you are targeting an obscure platform using a tool chain that is 20 years out of date
- Athas 6y agoThere is no guarantee that the hardware supports 8-bit numbers natively, and emulating them might be expensive. For embedded programming, it is sometimes useful to ask for a type that is at least 8 bits, but may be bigger.
- fanf2 6y agoThat’s what int_least8_t or int_fast8_t are for https://en.wikipedia.org/wiki/C_data_types#stdint.h https://en.wikipedia.org/wiki/C_data_types#stdint.h
- fjg 6y agoYou can choose to use int_least_8_t or int_fast8_t as the implementation type blc_int8 of Blech type int8 for code generation https://github.com/boschresearch/blech/blob/master/src/blechc/include/blechconf.h https://github.com/boschresearch/blech/blob/master/src/blech... So you can adopt to your needs on your platform.
- iainmerrick 6y agoOut of interest, are there particular platform(s) you have in mind? I remember working with TI C5x DSPs which had 16-bit "bytes", but that was a long time ago. I'm curious whether there are still important embedded platforms that you might target with C and have unusual addressable word sizes.