1

According to the question, i tried to do it as following:

#include <android/log.h>

#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#define TAG "mylog"
#define LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)

uint64_t value = 9999999999;
LOGD("test print uint64_t: %" PRIu64 "\n", value);

However, i got the errors as following:

error: expected ')' before 'PRIu64'
LOGD("test print uint64_t: %" PRIu64 "\n", value);

How to print the uint64_t in Android?

Community
  • 1
  • 1
Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71
  • Did you include stdint.h? – Lundin Sep 16 '15 at 07:39
  • 1
    @Lundin: `PRIu64` is defined in `inttypes.h` (which btw includes `stdint.h`). – Michael Sep 16 '15 at 07:40
  • @Michael Aha, didn't know inttypes was required to include stdint. – Lundin Sep 16 '15 at 07:43
  • Then the next thing to check is adding this macro: `#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901) #error Your compiler was made by dinosaurs. #endif` – Lundin Sep 16 '15 at 07:47
  • @Lundin still compile error after include stdint.h – Jerikc XIONG Sep 16 '15 at 08:01
  • Yes, according to the comments above, you don't need to do that, given that you include inttypes.h. So the question is what compiler you are using, does it support C99/C11 and if so, is it set to compile the code as C99/C11? – Lundin Sep 16 '15 at 09:46

0 Answers0