记录变量的值在原生的Android NDK [英] Logging values of variables in Android native ndk
本文介绍了记录变量的值在原生的Android NDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设置了C ++在Android的NDK记录。
我可以打印一个消息给logcat的是这样的:
__ android_log_write(ANDROID_LOG_INFO标签在这里,消息在这里);
现在让我们说我有一个名为testint一个整数。我怎样才能打印此整型值?
像这样打印地址,但我想要的值。我还没有发现在C ++中如何做到的事。感谢您的帮助!
__ android_log_print(ANDROID_LOG_INFO,sometag,%P,*试验);
解决方案
您可以使用 __ android_log_print
它采用了的sprintf
样的语法格式将数据转换为字符串。
__ android_log_print(ANDROID_LOG_INFO,sometag,内部测试=%d个,testInt);
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", "message here");
Now let's say I have an integer called testint. How can I print the value of this int?
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);
解决方案
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屋!
查看全文