Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is __null defined in g++?

Tags:

null

g++

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?

like image 824
wenlujon Avatar asked Jan 09 '12 03:01

wenlujon


Video Answer


1 Answers

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.

like image 156
David Schwartz Avatar answered Dec 13 '22 10:12

David Schwartz