Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange NOOP convention?

Tags:

c

pebble-watch

I was browsing a template (at cloudpebble.net) for building a Pebble watch face and came across this code:

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

}

What purpose do the lines I've indicated serve?

like image 268
Cade Roux Avatar asked Dec 26 '22 04:12

Cade Roux


1 Answers

The only purpose of those lines is to silence compiler warnings like -Wunused-parameter. Note that those variables aren't used anywhere in the function body; casting them to void essentially tells the compiler that that's intentional.

like image 144
Cairnarvon Avatar answered Dec 31 '22 11:12

Cairnarvon