3

This is some C code from the Make Controller firmware. I'm familiar with what void pointers are, but I've never seen syntax like the first line of this function. What precisely is being accomplished by that?

void MakeStarterTask(void* parameters)
{
  (void)parameters;
  Run();
  TaskDelete(NULL);
}
Andrew Spiehler
  • 209
  • 1
  • 2
  • 8

3 Answers3

5

It "uses" parameters so the compiler won't emit a warning about an unused parameter, but the expression does itself nothing. Any expression can be cast to void, which discards the result.

(Keep in mind that the expression is still evaluated; to make an expression completely ignored is trickier.)

Community
  • 1
  • 1
GManNickG
  • 494,350
  • 52
  • 494
  • 543
1

It's probably there to suppress a compiler warning about an unreferenced parameter, like the UNREFERENCED_PARAMETER macro.

user541686
  • 205,094
  • 128
  • 528
  • 886
0

Instructs the compiler not to complain about the unused parameters parameter.

vz0
  • 32,345
  • 7
  • 44
  • 77