Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.std.c,comp.arch.embedded Subject: Re: Making more of the C standard library mandatory for freestanding implementations Date: Wed, 06 May 2020 13:22:00 -0700 Organization: None to speak of Lines: 48 Message-ID: <87pnbgzudz.fsf@nosuchdomain.example.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="dcfcb51887ac7802667ee20ddc196f88"; logging-data="2300"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/38Qm58GIc1cP/BHKON+7R" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:cS2khNSunR/fy0hr0yAfzo/Csyw= sha1:Blj7QHmRWhTFdQAOh9v7AITn8Vw= Xref: csiph.com comp.std.c:6083 comp.arch.embedded:29617 Richard Damon writes: > On 5/6/20 3:10 PM, James Kuyper wrote: >> On 5/6/20 2:10 PM, Grant Edwards wrote: >>> On 2020-05-06, Philipp Klaus Krause wrote: >>>> Am 06.05.20 um 18:47 schrieb Grant Edwards: >>>>>> >>>>>> Do you see any reason those could not be provided on some C >>>>>> implementation? >>>>> >>>>> Memory size. >>>> >>>> Could you elaborate? >>>> >>>> I do not see a problem there: If the programmer doesn't use e.g. >>>> memcpy(), no memcpy() will be linked in, so memory size would not be >>>> affected. >>> >>> Would that be required by the spec? >> >> No, but it might be required by the marketplace. If you had a choice of >> two compilers, one of which always links in standard library routines >> even if they're unused, and the other of which only links them in if >> they are used, which one would you select, particularly if targeting a >> platform with only limited memory? Do you think there's any significant >> number of people who would choose differently? > > By that same logic, people will chose the implementation that implement > more of the optional headers (or at least the ones they want) over those > that don't. There is nothing in the Standard to say that they can't > implement the part that aren't required. True. On the other hand, there's nothing in the Standard to say that a freestanding implementation that implements part of the hosted standard library has to do it correctly. You probably wouldn't want to require that. For example, an implementation might reasonably provide printf but not fprintf, or provide printf but without floating-point support. It would be difficult to define the requirements for partial support. It's probably good enough that a freestanding implementation's documentation can say something like "We support as specified by C11 with the following exceptions ...". -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */