PRIx64 issue on SLES 11

Hey guys,

I’m having trouble with PRIx64 and buddies in the X86 target on SLES 11. After searching, my issue seems like a generic problem with PRI support on different OS’s.

Here’s a decent description of my problem:

http://gcc.gnu.org/ml/gcc-help/2006-10/msg00221.html

Any suggested methods to correct for <inttypes.h> not having the proper macros defined (besides defining the macros myself)? Has anyone else had trouble with these macros?

Ty,

Cameron

Well, Ian is correct. If you build with a C++ compiler, you need to
define __STDC_FORMAT_MACROS.

Joerg

Someone suggested that I explicitly define the macro __STDC_FORMAT_MACROS, which seems safe enough.

If anyone has experience with this macro, I would appreciate any more information.

Thanks again,
Cameron

This is a problem with C/C++. <inttypes.h> is a C99 feature, not included in C++03. (corresponding to <inttypes.h> in C) is included in C++11.

If you want to use a C++ compiler (instead of C), you may use ‘clang++ -D__STDC_FORMAT_MACROS=’ as suggested by Joerg.

It is also possible to replace <inttypes.h> with . Using clang++ 3.1 (I assume you not use g++ version 3.4.6 as in the description :wink: you get:

/usr/lib64/gcc/x86_64-suse-linux/4.3/…/…/…/…/include/c++/4.3/c++0x_warning.h:36:2: error: This file requires compiler and library support for the upcoming ISO
C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.

using ‘clang++ -std=c++11’, gives

xxx.c:8:35: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]

i.e. you need to insert spaces around PRIx64, but otherwise work as expected.

/Patrik Hägglund