stdcall stdcall - 1 month ago 4x
C Question

Ignoring return values in C

Lately, I started using lint for static code analysis.
One of the warning I get sometimes is regarding this issue.
Let's say for instance that I've got the following function:

uint32_t foo( void );

And let's say that I delibertly ignore the return value of the function.
To make the warning dissapear, one can write

(void) foo();

My question is, what is the "proper" way to write code like this, should I continue as I always did, since the compiler doesn't complain about it, or should I use the void for clarity, so other code maintainer will know that I delibertly ignored the return value.

When I look at the code like this ( with the void ), it looks pretty strange to me...


The common way is to just call foo(); without casting into (void).

He who has never ignored printf()'s return value, cast the first stone.