c - 奇怪的 NOOP 约定?

标签 c pebble-watch

我正在浏览用于构建 Pebble 表盘的模板(位于 cloudpebble.net)并看到了这段代码:

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);
  }

}

我指定的行有什么作用?

最佳答案

这些行的唯一目的是消除编译器警告,例如 -Wunused-parameter。请注意,这些变量不会在函数体的任何地方使用;将它们转换为 void 本质上告诉编译器这是有意的。

关于c - 奇怪的 NOOP 约定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16290714/

相关文章:

c - sscanf 是否修改传递给它的字符串?

c - 在位操作中使用 'char' 变量

c - 怎样让它更漂亮?

javascript - SimplyJS 和 xml : get value of a key

android - 在 Android Studio 中重写 Gradle Remote Dependency 的 targetSdkVersion

c - 什么是c中的强类型?

c - 调试 C 程序

c - Linux 中的文件锁定

c - 鹅卵石 : How to pass an integer as callback_data with app_timer_register?

javascript - 如何让两个 Pebbles 互相交谈。最好将 javascript 与 Pebble.js 一起使用,但也可以使用 PebbleKit sdk 或标准 C Pebble