-2

I saw following code few times

void func(SomeTypeEGInt varname) {
    (void)varname;
}

I wish to know what it means and why people implement such functions.

Trismegistos
  • 3,745
  • 2
  • 20
  • 38

2 Answers2

2

It tell the compiler that those variables are unused. It is used to prevent the warnings which you will get.

Rahul Tripathi
  • 152,732
  • 28
  • 233
  • 299
  • 1
    additional, you cold achieve the same effect (suppress warning) by `void func( SomeTypeEGInt ) {...}` – lifeOfPI Jul 24 '14 at 13:05
1

The (void)varname; pattern is typically used to silence compiler warning about unused arguments. So this example is actually an empty function which does nothing.

DarkDust
  • 85,893
  • 19
  • 180
  • 214