开发者

Casting function returns to void

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜