4 ms·
Why do you think that believing that sizeof(int) == 4 is worse than believing that int32_t exists? It doesn't have to
by usrnm 3y ago
Why do you think that believing that sizeof(int) == 4 is worse than believing that int32_t exists? It doesn't have to
- ska 3y agoIf a type doesn't exist in your toolchain, your compile will fail an you will know why. Conversely, incorrect assumptions about size/size/capacity can lead to subtle run-time bugs.
- deleted 3y ago[deleted]
- archi42 3y agoYou have to check sizeof(int) somewhere. Why not do that in a header? To make sure you're using the checked int, define a new type, eg "int4" in that header, too, and use that. Congratulations, you'll fulfill this MISRA rule :) Or just use int32_t and let the compiler fail if your Toolchain does not have that. Then just write an appropriate header to add it (with the correct checks) ;)