• <i id='1FyK7'><tr id='1FyK7'><dt id='1FyK7'><q id='1FyK7'><span id='1FyK7'><b id='1FyK7'><form id='1FyK7'><ins id='1FyK7'></ins><ul id='1FyK7'></ul><sub id='1FyK7'></sub></form><legend id='1FyK7'></legend><bdo id='1FyK7'><pre id='1FyK7'><center id='1FyK7'></center></pre></bdo></b><th id='1FyK7'></th></span></q></dt></tr></i><div id='1FyK7'><tfoot id='1FyK7'></tfoot><dl id='1FyK7'><fieldset id='1FyK7'></fieldset></dl></div>

    <small id='1FyK7'></small><noframes id='1FyK7'>

    <legend id='1FyK7'><style id='1FyK7'><dir id='1FyK7'><q id='1FyK7'></q></dir></style></legend>

        <tfoot id='1FyK7'></tfoot>
        • <bdo id='1FyK7'></bdo><ul id='1FyK7'></ul>

        指针的大小是多少?它具体取决于什么?

        时间:2023-09-15
          <tbody id='IBHLM'></tbody>
        <legend id='IBHLM'><style id='IBHLM'><dir id='IBHLM'><q id='IBHLM'></q></dir></style></legend>
        <i id='IBHLM'><tr id='IBHLM'><dt id='IBHLM'><q id='IBHLM'><span id='IBHLM'><b id='IBHLM'><form id='IBHLM'><ins id='IBHLM'></ins><ul id='IBHLM'></ul><sub id='IBHLM'></sub></form><legend id='IBHLM'></legend><bdo id='IBHLM'><pre id='IBHLM'><center id='IBHLM'></center></pre></bdo></b><th id='IBHLM'></th></span></q></dt></tr></i><div id='IBHLM'><tfoot id='IBHLM'></tfoot><dl id='IBHLM'><fieldset id='IBHLM'></fieldset></dl></div>

              1. <small id='IBHLM'></small><noframes id='IBHLM'>

                  <bdo id='IBHLM'></bdo><ul id='IBHLM'></ul>

                  <tfoot id='IBHLM'></tfoot>
                  本文介绍了指针的大小是多少?它具体取决于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在网上搜索,虽然可以找到一些讨论,但没有找到全面的描述.因此,如果任何人都可以形成一个涵盖有关指针大小的所有内容的答案,那将有很大帮助.答案至少应涵盖以下主题

                  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

                  1. 指针的大小取决于什么?
                  2. 架构的什么特性会影响指针的大小?(详细)
                  3. 编译器如何影响指针的大小?

                  推荐答案

                  指针是高级语言提供的抽象;理论上它可以是任何宽度.这完全是编译器的心血来潮.

                  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:

                  • 在大多数现代硬件上,您的程序将使用虚拟内存地址,而不是物理地址(它们的宽度可能不同).除非您正在编写内核空间代码.
                  • 在某些架构(例如 x86)上,底层硬件展示了一个分段地址空间.这确实很复杂,但大部分都被操作系统和虚拟内存系统抽象掉了.但是,如果您正在为非常老的 x86 编写内核空间代码或代码,则必须处理它.
                  • 在当前的 x86-64 上,(虚拟)内存地址实际上只有 48 位宽.
                  • x86-64 支持 32 位和 64 位可执行文件.
                  • 您可能正在一个虚拟机中运行,该虚拟机可以根据需要执行任何操作(相对于底层物理机).
                  • On most modern hardware, your program will work with virtual memory addresses, rather than physical addresses (which may not be the same width). Unless you're writing kernel-space code.
                  • On some architectures (e.g. x86), the underlying hardware exhibits a segmented address space. This is really complicated, but is mostly abstracted away by the OS and the virtual-memory system. If you're writing kernel-space code or code for really old x86s, you'll have to deal with it, though.
                  • On current x86-64, (virtual) memory addresses are actually only 48-bits wide.
                  • x86-64 supports both 32-bit and 64-bit executables.
                  • You may be running inside a virtual machine, which again can do whatever if it wants (relative to the underlying physical machine).

                  这篇关于指针的大小是多少?它具体取决于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何检测 c/c++ 程序中可能/潜在的堆栈溢出问题 下一篇:GCC 中地址清理器的有意义的堆栈跟踪

                  相关文章

                  最新文章

                      <bdo id='6QJL4'></bdo><ul id='6QJL4'></ul>
                  1. <legend id='6QJL4'><style id='6QJL4'><dir id='6QJL4'><q id='6QJL4'></q></dir></style></legend>
                  2. <i id='6QJL4'><tr id='6QJL4'><dt id='6QJL4'><q id='6QJL4'><span id='6QJL4'><b id='6QJL4'><form id='6QJL4'><ins id='6QJL4'></ins><ul id='6QJL4'></ul><sub id='6QJL4'></sub></form><legend id='6QJL4'></legend><bdo id='6QJL4'><pre id='6QJL4'><center id='6QJL4'></center></pre></bdo></b><th id='6QJL4'></th></span></q></dt></tr></i><div id='6QJL4'><tfoot id='6QJL4'></tfoot><dl id='6QJL4'><fieldset id='6QJL4'></fieldset></dl></div>

                    <tfoot id='6QJL4'></tfoot>

                      <small id='6QJL4'></small><noframes id='6QJL4'>