Where is __null defined in g ++?

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

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

however, where is __null defined?

+4
source share
1 answer

The __null implementation is internal g ++. You will not find it in the header file or anything like that. You can find some explanation of the logic here , but the basic idea is that this is the easiest way to ensure that NULL is treated as a pointer in the first place.

Basically, the inside does what reinterpret_cast<void *>(0) would naively expect.

+6
source

Source: https://habr.com/ru/post/1389984/


All Articles