0

I have some code in my c++ file that looks like this:

#include <cinttypes>
....
LOG_INFO("%s duration: %" PRId64 "\n", tag.c_str(), timestamp);

And it can be compiled successfully with flag -std=c++11.

But it is failed been compiling on another machine with following error:

base/utils.h:68:31: error: expected ‘)’ before ‘PRId64’

unless I add flag -D__STDC_FORMAT_MACROS.

The first machine has

gcc "4.8.5 20150623 (Red Hat 4.8.5-16)", 

the other machine has

gcc "4.8.5 20150623 (Red Hat 4.8.5-28)"

and using

touch foo.h ; gcc -E -dM foo.h

got same result expect the version macro.

I'm confused why the second machine needs -D__STDC_FORMAT_MACROS to compile PRId64?

jasonxia
  • 321
  • 1
  • 8

0 Answers0