[cfe-dev] Posix format strings

Paul Curtis plc at rowley.co.uk
Thu Dec 2 03:30:56 PST 2010


Hi all,

One of the things that currently annoys me, to a certain extent, is that
Clang can’t be configured to accept Posix-compliant format strings that
extend the standard C formats.  There are some applications that use Posix
extensions so it seems only right to at least try to support Posix format
strings as this is both an ISO and IEEE standard, after all.

It looks like some of this done, but isn’t correctly attributed.  For
instance, in ParsePrintfSpecifier there is:

    // Mac OS X (unicode) specific
    case 'C': k = ConversionSpecifier::CArg; break;
    case 'S': k = ConversionSpecifier::SArg; break;

The %C and %S formats are, in fact, defined in Posix, so more accurately
this could be commented // ISO/IEC 9945, IEEE Std 1003.1 aka POSIX.1.

The ‘ (tick) to introduce thousands grouping looks like low-hanging fruit
and should be easy to implement.

The %n$ (positional) version is a bit more of a challenge.

So, some questions:

(1) Is anybody other than me supportive of adding this feature to Clang?
(2) If so, should Posix format strings be accepted as default?
(3) Should there be a front-end flag to select Posix format support?

I would say that the %C, %D, %@, and %m extensions to ISO C are accepted
silently by Clang.  That is, there is no -W option to turn on diagnosis of
these extensions, which feels wrong.

--
Paul Curtis, Rowley Associates Ltd   http://www.rowley.co.uk
SolderCore arriving Winter 2010!   http://www.soldercore.com






More information about the cfe-dev mailing list