I'm not sure what you are trying to achieve, but ...
- 0 is of type signed int
- 0U is of type unsigned int
size_t requires type size_t - and sizes are (usually) unsigned
So, for strict compliance, size_t foo = 0U; , although it would be more correct to use size_t foo = (size_t)0;
As an aside, a discussion of whether 0 is a decimal, octal, or anything else does not matter ... it is still zero.
-
Edit to add:
Although the explicit conversion between signed and unsigned was deprecated in MISRA C: 2004 (although it was widely rejected), for MISRA C: 2012, Rule 10.3 explicitly allows a non-negative integer expression of a constant of essentially a signed type, an object of a substantially unsigned type can be assigned if its value can be represented by this type
This is the standard way to say you don't need U
source share