where is __null defined in g++?

2019-06-21 21:35发布

in g++, NULL is defined as __null, in 64-bit case, __null is 8 bytes. such as:

printf("sizeof(__null):%d, sizeof(0):%d\n", sizeof(__null), sizeof(0));
sizeof(__null):8, sizeof(0):4

however, where is __null defined?

标签: null g++
1条回答
爷、活的狠高调
2楼-- · 2019-06-21 21:44

The implementation of __null is as a G++ internal. You won't find it in a header file or anything like that. You can find some explanation of the logic here but the basic idea is that it's the simplest way to ensure NULL is seen as a pointer first.

Basically, the internal does what you would naively expect reinterpret_cast<void *>(0) to do.

查看更多
登录 后发表回答