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

Richard Smith richard at metafoo.co.uk
Wed Oct 10 21:34:32 PDT 2012


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.

On Wed, Oct 10, 2012 at 12:53 PM, Daniel Hofmann <daniel at trvx.org> wrote:

> Hi,
>
> I'm currently porting a program from g++/libstdc++ to clang/libcxx and
> was quite surprised that the platform independent printing using format
> constants, e.g. PRId64, produces errors with libcxx.
>
> A simple example which compiles fine w/o libcxx or g++
> > #include <cstdio>
> > #include <cinttypes>
> >
> > int main() {
> >   int64_t n = 1;
> >
> >   printf("%" PRId64, n);
> > }
>
> w/ -stdlib=libcxx
> > +7:14: error: expected ')'
> >   printf("%" PRId64, n);
> >              ^
> > +7:9: note: to match this '('
> >   printf("%" PRId64, n);
> >         ^
>
> Although the cinttypes header comments lists them
> > Macros:
> >     ...
> >     PRId64
>
>
> So, what am I missing here? Is this not yet supported? How am I supposed
> to handle this?
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121010/13830972/attachment.html>


More information about the cfe-dev mailing list