size of pointers and architecture

前端 未结 9 2101
深忆病人
深忆病人 2020-12-07 00:40

By conducting a basic test by running a simple C++ program on a normal desktop PC it seems plausible to suppose that sizes of pointers of any type (including pointers to fun

9条回答
  •  攒了一身酷
    2020-12-07 01:00

    For correctness, you cannot assume anything. You have to check and be prepared to deal with weird situations.

    As a general rule of thumb, it is a reasonable default assumption.

    It's not universally true though. See the X32 ABI, for example, which uses 32bit pointers on 64bit architectures to save a bit of memory and cache footprint. Same for the ILP32 ABI on AArch64.

    So, for guesstimating memory use, you can use your assumption and it will often be right.

提交回复
热议问题