Re: ICU4C proposal: Formalizing the ustdio format specifiers
Markus Scherer <[email protected]>
| Newsgroups | gmane.comp.lib.icu.general |
|---|---|
| Organization | IBM |
| Message-ID | <[email protected]> |
General comments: It is a great pain for portable code that C does not specify the widths of its built-in types. ICU4C uses int32_t, uint16_t etc. for good reasons. There is no way we will design any API for unknown-width types. I understand how C got this way. Sometime in the last 15 years they should have defined C types more strictly though. It has always worried me that there was no sure way to format an int32_t with printf(). Do I use %d or %ld? (On Win16 I would need the latter.) Similarly, %ls and %S and such are as useless (or even more so) for portable code using standard printf() as wchar_t itself. George's proposal simply contains format specifiers for what makes sense for APIs with defined-width types. The one place where I am not sure myself is %ld vs. %lld (and cousins %lu, %llx etc.). It would be nice and consistent to have each width specifier (h, <no width>, l) stand for a unique width (16, 32, 64 bits respectively); however, I know that some code is using %ld for 32-bit types (see above), and so porting might be a bit safer if both <no width> and (ell) were 32 bits wide and then (ell ell) be used for 64 bits. I don't care enough myself so far about this point to make a strong stand one way or another. markus -- Opinions expressed here may not reflect my company's positions unless otherwise noted.