Sujet : Re: Loops (was Re: do { quit; } else { })
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 23. Apr 2025, 18:52:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vub9d1$3kfla$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Mozilla Thunderbird
On 23/04/2025 18:05, David Brown wrote:
On 23/04/2025 00:02, Keith Thompson wrote:
C23 does not have _Lengthof. It's proposed for C2y.
>
Sorry, yes. The pdf I was viewing was the latest draft for post-C23 rather than C23. My mistake.
Actually, my C compiler has 'lengthof'. I'd got rid of most experimental bits in the lastest version, but that got left in:
#include <stdio.h>
int main(void) {
int A[100];
printf("%zu\n", lengthof(A)); # shows 100
}
Looking at the sources, it is a sub-operator of 'sizeof' and its implementation took under 30 extra lines.
It works for expressions and types, just like sizeof.