在Android本机ndk中记录变量的值 [英] Logging values of variables in Android native ndk

查看:99
本文介绍了在Android本机ndk中记录变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android NDK中使用 C ++ 设置日志记录。

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

我可以像这样打印一个消息到logcat:

I can print a message to logcat like this:

__android_log_write(ANDROID_LOG_INFO, "tag here", "message here");

现在,我有一个整数叫做 testint 。如何打印这个int的值?

Now let's say I have an integer called testint. How can I print the value of this int?

像这样打印地址,但是我想要这个值。我没有在 C ++ 中找到任何关于如何做到这一点。感谢任何帮助!

Something like this prints the address, but I want the value. I haven't found anything in C++ on how to do this. Thanks for any help!

__android_log_print(ANDROID_LOG_INFO, "sometag", "%p", *test);


推荐答案

您可以使用 __ android_log_print 它使用一个 sprintf 类似的语法,将您的数据格式化为字符串。

You could use __android_log_print which uses a sprintf-like syntax that formats your data into a string.

__android_log_print(ANDROID_LOG_INFO, "sometag", "test int = %d", testInt);

这篇关于在Android本机ndk中记录变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆