2

I'm not able to get rid of this warning:

warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ [-Wformat=] printf("my_number: %#016llx\n", my_number);

In my_test.c:

#include <stdint.h>
#include <stdio.h>

int main(int argc, char argv[])
{
  uint64_t my_number = 0x0706050403020100;
  printf("my_number: %#018llx\n", my_number);

  return 0;
}

ANSWER

#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>

int main(int argc, char argv[])
{
  uint64_t my_number = 0x0706050403020100;
  printf("my_number: %#018" PRIx64 "\n", my_number);

  return 0;
}
tarabyte
  • 17,837
  • 15
  • 76
  • 117
  • 1
    You should search before you ask. [Here is an identical question to yours](http://stackoverflow.com/questions/9225567/how-to-print-a-int64-t-type-in-c). – JS1 May 30 '15 at 08:26
  • Converting to `unsigned long long` is not unreasonable, since that type is guaranteed to be at least 64 bits wide. – Keith Thompson May 30 '15 at 08:30

0 Answers0