0xDEADBEEF equivalent for 64-bit development?

前端 未结 12 795
栀梦
栀梦 2021-02-02 06:46

For C++ development for 32-bit systems (be it Linux, Mac OS or Windows, PowerPC or x86) I have initialised pointers that would otherwise be undefined (e.g. they can not immedi

12条回答
  •  你的背包
    2021-02-02 06:58

    As the system I worked on basically runs on x86_64 platform, the value I use is:

    0xDEADBEEFDEADBEEF
    

    Reasons are:

    • On x86_64 platform, only the low-order 48 bits are used for virtual memory address in current implementation, meaning any value > 2^48 should work: https://en.wikipedia.org/wiki/X86-64
    • As 0xDEADBEEF is already very well known for this purpose in 32bit, 0xDEADBEEFDEADBEEF in 64bit is just more 'backward compatible'

提交回复
热议问题