[cfe-dev] libcxx: Platform independent printing using format constants

Richard Smith richard at metafoo.co.uk
Thu Oct 11 16:47:25 PDT 2012


On Thu, Oct 11, 2012 at 10:56 AM, Howard Hinnant <hhinnant at apple.com> wrote:

>
> On Oct 11, 2012, at 12:35 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> > On Wed, Oct 10, 2012 at 9:34 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
> > libc++ does this to pick up the macro definitions:
> >
> > #include <inttypes.h>
> >
> > However, glibc's inttypes.h only provides them in C++ mode if
> _STDC_FORMAT_MACROS is defined, and libc++ doesn't define it.
> >
> > Sorry, needs more underscore: __STDC_FORMAT_MACROS.
>
> Right.  This is C++11-conforming.  27.9.2 [c.files]/p3:
>
> > Table 135 describes header <cinttypes>. [ Note: The macros defined by
> <cinttypes> are provided unconditionally. In particular, the symbol
> __STDC_FORMAT_MACROS, mentioned in footnote 182 of the C standard, plays no
> role in C++. — end note ]
>
> Summary:  <inttypes.h> should not be protecting anything in C++ based on
> __STDC_FORMAT_MACROS, despite the non-normative footnote in C99's 7.8.1.
>  When the C++ committee looked at this issue, they told the C committee
> "thanks but no thanks.".


Right, but glibc follows the C99 standard, not the C++11 standard (nor the
C11 standard, which removes this unwanted "protection"), so cinttypes needs
to define __STDC_FORMAT_MACROS itself if it's going to include a C99
<inttypes.h> header such as glibc's.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121011/30b748f0/attachment.html>


More information about the cfe-dev mailing list