我想在我的Android应用程序中使用libbacktrace,我不知道如何构建它......
现在我尝试通过脚本构建lib:
#!/bin/bash
ndk-build \
APP_BUILD_SCRIPT=libbacktrace/Android.mk \
NDK_PROJECT_PATH=. \
APP_STL=stlport_static \
LOCAL_C_INCLUDES+=include \
LOCAL_C_INCLUDES+=../../../android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include \
LOCAL_C_INCLUDES+=../../../android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include/ \
APP_PLATFORM=android-19
我有错误:
[armeabi] Compile++ thumb: backtrace <= BacktraceImpl.cpp
libbacktrace/BacktraceImpl.cpp: In member function 'virtual std::string Backtrace::FormatFrameData(const backtrace_frame_data_t*)':
libbacktrace/BacktraceImpl.cpp:117:48: error: expected ')' before 'PRIxPTR'
snprintf(buf, sizeof(buf), "#%02zu pc %0*" PRIxPTR " %s (%s+%" PRIuPTR ")",
^
libbacktrace/BacktraceImpl.cpp:119:58: error: conversion lacks type at end of format [-Werror=format=]
frame->func_name.c_str(), frame->func_offset);
^
libbacktrace/BacktraceImpl.cpp:119:58: error: too many arguments for format [-Werror=format-extra-args]
libbacktrace/BacktraceImpl.cpp:121:48: error: expected ')' before 'PRIxPTR'
snprintf(buf, sizeof(buf), "#%02zu pc %0*" PRIxPTR " %s (%s)", frame->num,
^
libbacktrace/BacktraceImpl.cpp:122:87: error: conversion lacks type at end of format [-Werror=format=]
(int)sizeof(uintptr_t)*2, relative_pc, map_name, frame->func_name.c_str());
^
libbacktrace/BacktraceImpl.cpp:122:87: error: too many arguments for format [-Werror=format-extra-args]
libbacktrace/BacktraceImpl.cpp:124:48: error: expected ')' before 'PRIxPTR'
snprintf(buf, sizeof(buf), "#%02zu pc %0*" PRIxPTR " %s", frame->num,
^
libbacktrace/BacktraceImpl.cpp:125:61: error: conversion lacks type at end of format [-Werror=format=]
(int)sizeof(uintptr_t)*2, relative_pc, map_name);
^
libbacktrace/BacktraceImpl.cpp:125:61: error: too many arguments for format [-Werror=format-extra-args]
cc1plus: all warnings being treated as errors
make: *** [obj/local/armeabi/objs/backtrace/BacktraceImpl.o] Error 1
我明白我做错了什么但我不知道是什么......
答案 0 :(得分:0)
PRIxPTR
的定义看起来有问题(它应该是一个宏)。
IIRC类型是 printf()格式中的“主要”字母,例如i
中的%i
,有关详细信息,请参阅printf格式的规范。 (哎呀...它被正式称为说明符,并且还有一个可选的长度子说明符,但是你看到了这一点。但是M $称它们为“printf Type”字段字符“)。
在C中,"a" "b"
与"ab"
相同,因此在#define X "i"
之后,文字"%" X
相当于"%i"
。