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

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

问题描述

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

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

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

然而,__null 在哪里定义?

however, where is __null defined?

推荐答案

__null 的实现是作为 G++ 内部的.你不会在头文件或类似的东西中找到它.您可以在 此处 找到对逻辑的一些解释,但基本思想是这是确保首先将 NULL 视为指针的最简单方法.

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.

基本上,内部会做您天真地期望 reinterpret_cast(0) 做的事情.

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

这篇关于__null 在 g++ 中定义在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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