Can size of pointers to non-union classes differ?

后端 未结 2 885
长发绾君心
长发绾君心 2021-01-05 06:52

I understand there are HW platforms where you need more information to point to a char than you need to point to an int (the platform having non-ad

2条回答
  •  时光取名叫无心
    2021-01-05 07:12

    As far as I understand C and C++ assume memory to be linearly byte addressable. Certain platforms (early ARM) however insist on word aligned loads and stores. In such a case, it is the compiler's responsibility to round the pointer to the word boundary and then perform the necessary bit shift operations when fetching say a char.

    But since this is all done only on loads and stores, all pointers still all look the same.

提交回复
热议问题