1、解决LOCAL_CFLAGS := -Werror ,出现 unused parameter的问题。

void SetBuffCount(uint32_t count) { }
error: unused parameter ‘count’ [-Werror,-Wunused-parameter]

    1. 声明函数时,只写参数类型,不写参数名

原因:编译器 找到声明 只做类型检查的,就能给临时变量分配空间。具体类型名,不调用无所谓。可以省略形参的参数名,而只保留类型。
void SetBuffCount(uint32_t /* count */) { }

    1. 增加打印

void SetBuffCount(uint32_t count) { printf("%d", count); }

    1. (void)变量

原因:这只是一种防止编译器编译时报警告的用法。有些变量如果未曾使用,在编译时是会报错,从而导致编译不过,所以才会出现这种用法。而此语句在代码中没有具体意义,只是告诉编译器该变量已经使用了。
void SetBuffCount(uint32_t count) { (void)count; }

2.

warning: instantiation of variable ‘MyClass::alloc’ required here, but no definition is available [-Wundefined-var-template]
回答:Because MyClass is a template, the compiler expects all the code for the templated class to be available in the same file (myclass.h). Since you only declare but do not define alloc in myclass.h, the compiler assumes you made a mistake. It’s not absolutely required to be there and you could disable the warning if you define the variable elsewhere, but it’s almost certainly just a mistake.
if you’re using c++17, the easiest way to deal with this is to declare the static member as inline, so it will be defined right there:
static inline std::allocator alloc;
live: https://godbolt.org/g/cr1aUP
Alternatively, you can explicitly define the variable in myclass.h:
template std::allocator MyClass::alloc;
live: https://godbolt.org/g/2Znqst