vfprintf() string precision type
Harti Brandt
hartmut.brandt at dlr.de
Sun Sep 16 23:37:37 PDT 2007
On Sun, 16 Sep 2007, Sean C. Farley wrote:
SCF>Xin LI noticed a warning in the code I wrote for setenv() where a
SCF>precision was provided with a string argument to warnx() (really
SCF>vfprintf()). The warning appearing on amd64 and not i386 showed that
SCF>precisions are always 32-bit.
SCF>
SCF>Would it be better to change the precision handling to expect size_t?
SCF>My reasoning is that strlen() and sizeof both return size_t. It makes a
SCF>cast unnecessary for passing a value returned by either call as the
SCF>precision. Unfortunately, I could find nothing from SUSv3 that
SCF>specified what type the precision could be.
The argument to the %.*f is specified to be an int (7.19.6.1/5) so I would
assume that internal handling in printf() also uses int. Paragraph 4 of
the above section talks about the precision as 'an optional decimal
integer'. Well, one could interpret this to mean int, but need not to.
harti
PS: Not sure that I got your question right :-)
More information about the freebsd-standards
mailing list