Why cast an unused function parameter value to void?

c, casting, void

Solution

It is there to avoid warnings from the compiler because some parameters are unused.

Problem

In some C project, I have seen this code: ``` static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } ``` Do the two casts to void serve any purpose?

Original source

Related problems