Many times I see in open source code that a call to a C function is cast to void.
For example, in the source code for ls
(http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr开发者_Python百科/src/cmd/ls/ls.c) I see the following.
(void) setlocale(LC_ALL, "");
Why is this good practice?
It explicitly means you ignore the return value, and did not just forget it.
精彩评论