我在网上搜索,虽然可以找到一些讨论,但没有找到全面的描述.因此,如果任何人都可以形成一个涵盖有关指针大小的所有内容的答案,那将有很大帮助.答案至少应涵盖以下主题
I searched online and while I could find a few discussions, I did not find a comprehensive description. So if anyone could form an answer which covers everything about size of a pointer, it would be of great help. The answer should at least cover following topics
指针是高级语言提供的抽象;理论上它可以是任何宽度.这完全是编译器的心血来潮.
A pointer is an abstraction provided by a high-level language; in theory it could be any width at all. It's totally at the whim of the compiler.
在实践中,它通常与底层硬件的内存地址的宽度有关,因为这通常是编译器实现的最有效的东西.不过也有例外;例如,C++ 的成员函数指针没有直接映射到硬件地址,因为它需要表示两个实体(函数和类型的一些概念).
In practice, it's typically related to the width of the memory addresses of the underlying hardware, as that's usually the most efficient thing for the compiler to implement. There are exceptions though; for example, C++'s pointer-to-member-function does not have a direct mapping to hardware addresses, as it needs to represent two entities (the function and some notion of the type).
然而,即使撇开这一点,仍然存在复杂性.例如:
However, even leaving that aside, there are still complexities. For example:
这篇关于指针的大小是多少?它具体取决于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!