[Cfp-interest] freestanding

Joel C. Salomon joelcsalomon at gmail.com
Sat Feb 25 20:00:36 PST 2012


On 02/24/2012 11:33 AM, Jim Thomas wrote:
> Feedback from the C committee urged the following changes to our draft
> TS Part 1:
> 
>   * Allow freestanding implementations to conform. 
<snip>
> A key issue for the first one is avoiding the requirement for
> freestanding implementations to support <stdlib.h> and <stdio.h>. Below
> is a draft specification for a new header that provides the character
> sequence conversion functionality required by IEEE 754. Please look it
> over and send comments. I'd be particularly interested in hearing from
> Joel, who first asked for this facility.
<snip>
> n          Floating-point string conversions <floatstr.h>
>  
> The header <floatstr.h> defines one type and five functions for
> converting between floating types and decimal character sequences.

Looks good to me.  The simplicity of specification is a very strong
argument in favor of what you've written.

> #include <floatstr.h>
> int strfromd(char * restrict s, size_t n, const char * restrict format, double x);
> int strfromld(char * restrict s, size_t n, const char * restrict format, long double x);

Might it be reasonable, for reasons of completeness, to also define
strfromf, or does the lack of a float-specific format make this too
confusing?

I could go either way on this, but if there is no strfromf, add a note
that strfromd doubles as the IEEE 754-mandated
single-precision-to-string operation. [pun intended]

[I assume it will be obvious to the Standards folks (though it took me a
moment to recognize this) that you're suggesting strfromd rather than
dtostr in order to keep to the reserved name-space.]

--Joel


More information about the Cfp-interest mailing list