C 64-bit Pointer Alignment

前端 未结 5 1003
野性不改
野性不改 2021-01-02 01:39

Are pointers on a 64-bit system still 4 byte aligned (similar to a double on a 32 bit system)? Or are they note 8 byte aligned?

For example, on a 64-bit system how

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-02 02:17

    I don't think you can rely on any hard-and-fast rules. I think it's a function of the compiler you use and the compilation options you choose.

    Your best bet is to write a program that tests this and spits out a header file that codifies the alignment rules as #defines. You might also be able to just calculate what you're interested in right in the macros, too.

提交回复
热议问题