我正在浏览一个模板(在cloudpebble.net上),用于构建Pebble表盘并遇到以下代码:
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {
(void)t; // NOOP?
(void)ctx; // NOOP?
display_time(t->tick_time);
}
void handle_init(AppContextRef ctx) {
(void)ctx; // NOOP?
window_init(&window, "Big Time watch");
window_stack_push(&window, true);
window_set_background_color(&window, GColorBlack);
resource_init_current_app(&APP_RESOURCES);
// Avoids a blank screen on watch start.
PblTm tick_time;
get_time(&tick_time);
display_time(&tick_time);
}
void handle_deinit(AppContextRef ctx) {
(void)ctx; // NOOP?
for (int i = 0; i < TOTAL_IMAGE_SLOTS; i++) {
unload_digit_image_from_slot(i);
}
}
Run Code Online (Sandbox Code Playgroud)
我指出的线路用于什么目的?
在我目前的程序中,我已经定义了一个函数
void functionName( const customClass object );
现在,在此函数的代码中,不使用此对象.我无权删除参数,也无法删除unused parameter警告.
有没有我可以用这个对象执行的语句(customClass没有我可以在这里运行的任何函数),所以这个警告不会发生?
我正在清理给定代码的所有警告.(这意味着我并不完全理解每一行逻辑)."[-Wunused-parameter]"已启用且不应关闭.
对于"未使用的参数",我们通常只使用"_ _ attribute _ _((unused))".
对于以下功能,我不能使用上述技巧.
void fun(int* a =0){
----variable ptr a is not used at all----
}
Run Code Online (Sandbox Code Playgroud)
有一个干净的解决方案去除警告的任何好主意?
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, …Run Code Online (Sandbox Code Playgroud)