John Smith wrote, On 22/01/07 15:04:
CBFalconer wrote:
>jacob navia wrote:
>>David Marsh a écrit :
I accidentally typed %b instead of %d in a printf format string
and got a binary representation of the number. Is that standard
C or a compiler extension?
It is used in the lcc-win32 compiler system for binary
representation
Unless you have means to disable it, that is another variation from
the standard and a hindrance to creating portable code.
I suppose you could use that logic to argue against *any* extension.
Isn't it the programmer's job to understand that it's non-standard and
avoid it in code intended to be portable?
It is also the implementers job to make a clear distinction between what
is standard and what is an extension. One problem is that Jacob as an
implementer often fails to make this distinction, although in this
particular case it could be argued that by saying "It is used in the
lcc-win32 compiler" he *is* saying it is specific to his compiler. I
suspect that were it not for his track record the post would have been
less likely lead to Chuck making the comment, or at least that he might
have phrased it differently.
Of course, it would be nice if in standards compliant mode it produced a
diagnostic (or run time message) for it, but that is something that
probably a lot of implementers would not bother with. After all, there
is no *requirement* in the standard to diagnose format specifiers not in
the standard, and in some situations it can only be detected at run time
in any case.
--
Flash Gordon