通常都说“null pointer constant”不说“NULL pointer constant”


所有跟贴·加跟贴·新语丝读书论坛

送交者: Yush 于 2009-03-16, 03:16:40:

回答: NULL的情况不一样 由 eng 于 2009-03-16, 02:29:52:

“null pointer constant”其值为0或(void*)0或NULL。
单独说“pointer constant”那是我民科扩展:)

引用:
C in a Nutshell: A Desktop Quick Reference - Google Books Result
A null pointer constant is an integer constant with the value 0, or a constant integer value of 0 cast as a pointer to void.

引用:
From C99:
An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.

引用:
http://www.gnu.org/software/libtool/manual/libc/Null-Pointer-Constant.html
A.3 Null Pointer Constant

The null pointer constant is guaranteed not to point to any real object. You can assign it to any pointer variable since it has type void *. The preferred way to write a null pointer constant is with NULL.
— Macro: void * NULL

This is a null pointer constant.

You can also use 0 or (void *)0 as a null pointer constant, but using NULL is cleaner because it makes the purpose of the constant more evident.






所有跟贴:


加跟贴

笔名: 密码: 注册笔名请按这里

标题:

内容: (BBCode使用说明