我的默认字符类型是 gcc 选项 (-funsigned-char gcc) 中设置的“无符号字符”。所以可以说,当我在代码中需要“unsigned char”时,我可以使用“char”。但是我收到了关于 (char*) 和 (unsigned char* 或 signed char*) 之间转换的警告:
"error: pointer targets in passing argument 1 of 'test2' differ in signedness"
.
当我将 unsigned char* 变量传递给 char* 时,如何避免警告(知道我的系统具有编译器选项设置的默认 unsigned char)?
static void test2(char* a) //char is unsigned by deafult as set by -funsigned-char gcc option
{
}
void test1(void)
{
// This passes, but if i change it to unsigned char (or 'signed char') it fails
// I dont want it to fail for "unsigned char c" since default char is unsigned.
char c = 65;
test2(&c);
}