Logging values of variables in Android native ndk

后端 未结 4 1777
甜味超标
甜味超标 2021-01-30 16:33

I set up logging with C++ in Android NDK.

I can print a message to logcat like this:

__android_log_write(ANDROID_LOG_INFO, \"tag here\", \"mess         


        
4条回答
  •  萌比男神i
    2021-01-30 16:49

    __android_log_print() takes a format string and a variable argument list. The format specifier you're looking for to print out a signed integer is "%d". So something like this is what you want:

    int foo = 42;
    __android_log_print(ANDROID_LOG_INFO, "SomeTag", "foo is %d", foo);
    

    For more information on format strings, you can see the sprintf manual.

提交回复
热议问题