where is __null defined in g++?

前端 未结 1 442
眼角桃花
眼角桃花 2020-12-19 11:07

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));
siz         


        
相关标签:
1条回答
  • 2020-12-19 11:45

    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.

    0 讨论(0)
提交回复
热议问题