How do I find how C++ compiler implements something except inspecting emitted machine code?(除了检查发出的机器代码之外,我如何找到 C++ 编译器如何实现某些东西?)
问题描述
假设我制作了一组类来抽象某些东西,现在我担心我的 C++ 编译器是否能够剥离这些包装并发出非常干净、简洁和快速的代码.如何找出编译器决定做什么?
Suppose I crafted a set of classes to abstract something and now I worry whether my C++ compiler will be able to peel off those wrappings and emit really clean, concise and fast code. How do I find out what the compiler decided to do?
我知道的唯一方法是检查反汇编.这适用于简单代码,但有两个缺点 - 编译器在再次编译相同代码时可能会有所不同 而且机器码分析也不是小事,所以很费功夫.
The only way I know is to inspect the disassembly. This works well for simple code, but there're two drawbacks - the compiler might do it different when it compiles the same code again and also machine code analysis is not trivial, so it takes effort.
我还能如何找到编译器如何决定实现我在 C++ 中编写的代码?
How else can I find how the compiler decided to implement what I coded in C++?
推荐答案
恐怕你在这方面不走运.您试图找出编译器做了什么".编译器所做的是生成机器代码.反汇编只是机器代码的一种更易读的形式,但它不能添加不存在的信息.您无法通过查看汉堡包来了解绞肉机的工作原理.
I'm afraid you're out of luck on this one. You're trying to find out "what the compiler did". What the compiler did is to produce machine code. The disassembly is simply a more readable form of the machine code, but it can't add information that isn't there. You can't figure out how a meat grinder works by looking at a hamburger.
这篇关于除了检查发出的机器代码之外,我如何找到 C++ 编译器如何实现某些东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:除了检查发出的机器代码之外,我如何找到 C++ 编译器如何实现某些东西?


基础教程推荐
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01