On Fri, 27 Feb 2009, Sean D'Epagnier wrote:
Hi,
I just added support for printf and scanf of fixed point types to avr
libc. I wanted to handle:
Currently accum and fract work, but not short accum or short fract
This is not a problem for integers currently since they get type
promoted when passed with stdarg.
There is nothing in the fixed-point standard that is for or against
this.. it seems logical that short accum be promoted to accum and
short fract be promoted to fract in this case.
Does anyone have any opinions on this?
The promotion of float to double when passed to a variadic function is
considered a legacy anomaly. Thus, the default argument promotions
(applied to variable arguments) should be considered to be the integer
promotions, float to double, and nothing else. (In particular, it is
deliberate that float _Complex does not promote to double _Complex - see
DR#206 - and likewise float _Imaginary (not supported by GCC) does not
promote to double _Imaginary.)
Unless your promotion is defined as being one of the integer promotions,
it should thus not occur. Your printf implementation should call va_arg
with the correct unpromoted type when it is passed an appropriate one of
the fixed-point printf formats defined in the fixed-point TR.
--
Joseph S. Myers
jos...@codesourcery.com