在g ++中定义__null在哪里? [英] where is __null defined in g++?
本文介绍了在g ++中定义__null在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
printf(sizeof(__ null):%d,sizeof(0):%d\\\
, sizeof(__ null),sizeof(0));
sizeof(__ null):8,sizeof(0):4
然而, __null定义了吗?
解决方案
基本上,内部做你会天真地期望 reinterpret_cast< void *> ;(0)
要做。
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?
解决方案
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.
这篇关于在g ++中定义__null在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文