Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.std.c
Subject: Re: Making more of the C standard library mandatory for freestanding implementations
Date: Sat, 30 May 2020 02:04:00 -0700
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <86zh9prdz3.fsf@linuxsc.com>
References: <3e5a2404-f2a9-3503-31f6-1c0040d34945@t-online.de> <878si3bjwe.fsf@nightsong.com> <86blmyzbbt.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="50ca98e22833fa004f70febc55f67ad1"; logging-data="3038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SSZoi/GY/hjhG1EWYruK6O0A5saV+V/Y="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:xVujOMyq+9ck0efx7q/iu8/kGDk= sha1:O+EaWMIB9rOm9rqnfOterOS6KqM=
Xref: csiph.com comp.std.c:6127
Philipp Klaus Krause writes:
> Am 08.05.20 um 17:38 schrieb Tim Rentsch:
>
>> For example, under this scheme, we might do this:
>>
>> // File "fs_string.h"
>>
>> #include // string.h optional subset
>>
>> #if ! _Provides_strlen
>> extern size_t strlen( const char * );
>> #endif
>>
>> ...
>>
>> // File "fs_string.c"
>>
>> #include "fs_string.h"
>>
>> #if ! _Provides_strlen
>> size_t
>> strlen( const char *s ){
>> size_t r = 0;
>> while( *s++ ) r++;
>> return r;
>> }
>>
>> #endif
>>
>> Now the rest of the program can simply #include "fs_string.h",
>> and use strlen() just as it would if strlen() was supplied
>> by the implementation.
>
> But this example also shows that it is relatively easy to implement
> strlen(), so there is not much burden on implementations when requiring
> them to provide it. And it shows that strlen not being mandatory for
> freestanding implementations results in lots of duplicated code in
> software projects that target these implementations.
You already gave these arguments. They weren't convincing
before, and repeating them doesn't make them any more
convincing.