1

I use the following code to print an int64_t:

int64_t a = 100;
printf("%lld\n", a);

However, it produces a warning.

warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int64_t'

So, I go into stdint.h and find the definition:

# if __WORDSIZE == 64
typedef long int int64_t;
# else
__extension__
typedef long long int int64_t;
# endif

THe problem is that I use '%lld' to print a 'long int' in 64bit system. Although simply using '%ld' solve the warning, it causes portability problem since it doesn't work in 32bit system ('%ld' accounts for 32 bits).

Is there any portable method to print int64_t?

Min Fu
  • 789
  • 1
  • 6
  • 16
  • 3
    Use the macro `PRId64` from ``. [See here](http://stackoverflow.com/questions/9225567/how-to-print-a-int64-t-type-in-c). – M Oehm Nov 29 '14 at 08:17

0 Answers0