在g ++中定义__null在哪里? [英] where is __null defined in g++?

查看:229
本文介绍了在g ++中定义__null在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在g ++中,NULL被定义为__null,在64位的情况下,__null是8个字节。如:

  printf(sizeof(__ null):%d,sizeof(0):%d\\\
, sizeof(__ null),sizeof(0));
sizeof(__ null):8,sizeof(0):4

然而, __null定义了吗?

解决方案

。你不会在头文件或类似的东西中找到它。你可以在这里找到一些逻辑的解释,但其基本思想是这是最简单的方式,以确保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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆