4

I am exploring an sdk and I came across the following set of statements.

uint32_t init_time = 0;
init_time = get_current_time_in_ms();
(void)init_time; // What does this statement do?

My first thought was that this is a NULL check of some sorts but I tried zero and non-zero value in a test C code doing something similar but response in both case was the same.

Any help would be appreciated.

yashC
  • 887
  • 7
  • 20

2 Answers2

6

This statement does not do anything logically.

It is sometimes added to avoid warnings in compilers and Static Analysers for unused variables

Rishikesh Raje
  • 8,556
  • 2
  • 16
  • 31
4

(void) variable; is usually used to avoid unused variable warnings.

It doesn't do anything but the SDK dev might left it there for future use.

Bumsik Kim
  • 5,853
  • 3
  • 23
  • 39