开发者

Casting function returns to void

开发者 https://www.devze.com 2023-01-20 19:27 出处:网络
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百科/sr

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

精彩评论

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