<br><br><div class="gmail_quote">On Thu, Oct 11, 2012 at 6:36 PM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com" target="_blank">hhinnant@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Oct 11, 2012, at 7:47 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
<br>
>> On Thu, Oct 11, 2012 at 10:56 AM, Howard Hinnant <<a href="mailto:hhinnant@apple.com">hhinnant@apple.com</a>> wrote:<br>
>><br>
>> On Oct 11, 2012, at 12:35 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
>><br>
>> > On Wed, Oct 10, 2012 at 9:34 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
>> > libc++ does this to pick up the macro definitions:<br>
>> ><br>
>> > #include <inttypes.h><br>
>> ><br>
>> > However, glibc's inttypes.h only provides them in C++ mode if _STDC_FORMAT_MACROS is defined, and libc++ doesn't define it.<br>
>> ><br>
>> > Sorry, needs more underscore: __STDC_FORMAT_MACROS.<br>
>><br>
>> Right.  This is C++11-conforming.  27.9.2 [c.files]/p3:<br>
>><br>
>> > 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 ]<br>

>><br>
>> 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.".<br>

>><br>
> 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.<br>

<br>
</div></div>That solution won't make a C++11 conforming std::lib.  C++11 also defines <inttypes.h> that *always* provides these macros.<br>
<br>
glibc could also follow the C99 standard by not guarding with __STDC_FORMAT_MACROS.  C99 has no normative statements that say it shall guard with __STDC_FORMAT_MACROS.  The only statements it has to such an effect are non-normative.<br>

<br>
Additionally the #define __STDC_FORMAT_MACROS in <cinttypes> won't necessarily be effective.  Consider the case that <inttypes.h> has traditional include guards:<br>
<br>
#include <inttypes.h><br>
...<br>
#include <cinttypes><br>
...<br>
// PRId64 defined here?<br>
<br>
PRId64 may or may not be defined here depending upon whether <inttypes.h> put it under an include guard.<br>
<br>
<inttypes.h> is the right place to fix this bug.</blockquote><div><br></div><div>OK, but where do we work around the bug? Perhaps Clang should always define  __STDC_FORMAT_MACROS in C++ mode.</div></div>