除了检查发出的机器代码之外,我如何找到 C++ 编译器如何实现某些东西? [英] How do I find how C++ compiler implements something except inspecting emitted machine code?

查看:32
本文介绍了除了检查发出的机器代码之外,我如何找到 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++ 编译器如何实现某些东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆