当ar是一个结构体时,什么是(void)(ar)
static int ModifyStatus(struct LinkService* ar, const char* property, char* value, int len)
{
(void)(ar);
if (property == NULL || value == NULL) {
return -1;
}
/* modify status property*/
printf("Modify Receive property: %s(value=%s[%d])n", property, value,len);
if (strcmp(property,"CarControl") == 0) {
g_car_control_mode = CAR_DIRECTION_CONTROL_MODE;
car_direction_control_func(value);
} else if (strcmp(property, "ModularControl") == 0) {
g_car_control_mode = CAR_MODULE_CONTROL_MODE;
car_modular_control_func(value);
} else if (strcmp(property, "SpeedControl") == 0) {
g_car_control_mode = CAR_SPEED_CONTROL_MODE;
car_speed_control_func(value);
}
/*
* if Ok return 0,
* Otherwise, any error, return StatusFailure
*/
return 0;
}
当 ar 是一个结构体时,我无法理解这代表什么。非常感谢。之前我认为它是一个功能点。再次感谢。
回答
强制转换(void)
抑制编译器ar
未使用的警告。有时,您可能需要一个函数具有特定的签名以符合接口,但实际上并不需要使用所有参数。如果您的代码库使用-Werror
.
另请参阅:如何在 C 中抑制“未使用的参数”警告?