The problem is that when you perform a cast on the expression that is being incremented. The C99 standard says this in a footnote:
A cast does not yield an lvalue
And the post-increment operator requires an lvalue.
Note that due to operator precedence rules, the expression is equivalent to:
*(((void **)__o->next_free)++) = ((void *)datum);
Ie., the post-increment is acting on the void**
(on which pointer arithmetic is valid), not the dereferenced void*
(which is an lvalue and would be valid to post-increment - if pointer arithmetic were valid on void*
).
Also note that as a language extension, GCC permits pointer arithmetic on void*
(treating it similar to char*
).