This is all 100% standardized. C17 6.10.8.1:
__DATE__The date of translation of the preprocessing translation unit: a character string literal of the form"Mmm dd yyyy"… and the first character ofddis a space character if the value is
less than 10.
…
__TIME__The time of translation of the preprocessing translation unit: a character string literal of
the form"hh:mm:ss"
- “Mmm dd yyyy” = 11
- “hh:mm:ss” = 8
" "(the space you used for string literal concatenation) = 1- Null termination = 1
11 + 8 + 1 + 1 = 21
As for sizeof, a string literal is an array. Whenever you pass a declared array to sizeof, the array does not “decay” into a pointer to the first element, so sizeof will report the size of the array in bytes. In case of string literals, this includes the null termination, C17 6.4.5:
In translation phase 7, a byte or code of value zero is appended to each multibyte character sequence that results from a string literal or literals. The multibyte character sequence is then used to
initialize an array of static storage duration and length just sufficient to contain the sequence. For character string literals, the array elements have typechar, and are initialized with the individual
bytes of the multibyte character sequence.
(Translation phase 6 is also mentioned, which is the string literal concatenation phase. I.e string literal concatenation is guaranteed to happen before null termination is added.)
So it would appear that mikroC PRO is non-conforming/bugged. There’s lots of questionable embedded systems compilers out there for sure.