Are there any platforms where pointers to different types have different sizes?

前端 未结 7 1068
刺人心
刺人心 2020-11-22 12:40

The C standard allows pointers to different types to have different sizes, e.g. sizeof(char*) != sizeof(int*) is permitted. It does, however, require that if a

相关标签:
7条回答
  • 2020-11-22 13:10

    It is possible that the size of pointers to data differs from pointers to functions for example. It is common for this to occur in microprocessor for embedded system. Harvard architecture machines like dmckee mentioned makes this easy to happen.

    It turns out that it makes gcc backends a pain to develop! :)

    Edit: I can't go into the details of the specific machine I am talking about but let me add why Harvard machines make this easy to happen. The Harvard architecture has different storage and pathways to instructions and data, therefore if the bus for the instructions is 'larger' than the one for data, you're bound to have a function pointer whose size is bigger than a pointer to data!

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