Do all C++ compilers generate C code?(所有 C++ 编译器都生成 C 代码吗?)
问题描述
可能是一个相当模糊和广泛的问题,但所有 C++ 编译器是否都先将代码编译成 C 再编译成机器代码?
Probably a pretty vague and broad question, but do all C++ compilers compile code into C first before compiling them into machine code?
推荐答案
由于 C 编译器几乎无处不在,并且几乎在每个平台上都可用,因此许多(已编译)语言在开发过程中都会经历这个阶段以引导该过程.
Because C compilers are nearly ubiquitous and available on nearly every platform, a lot of (compiled) languages go through this phase in their development to bootstrap the process.
在语言开发的早期阶段,要查看该语言是否可行,最简单的获得工作编译器的方法是构建一个编译器,将您的语言转换为 C,然后让本地 C 编译器构建实际的二进制文件.
In the early phases of language development to see if the language is feasible the easiest way to get a working compiler out is to build a compiler that converts your language to C then let the native C compiler build the actual binary.
这样做的问题是语言特定的结构丢失了,因此可能会错过潜在的优化机会,因此第二阶段的大多数语言都有自己的专用编译器前端,它可以理解语言特定的结构并可以从而提供基于这些结构的优化策略.
The trouble with this is that language specific constructs are lost and thus potential opportunities for optimization may be missed thus most languages in phase two get their own dedicated compiler front end that understands language specific constructs and can thus provide optimization strategies based on these constructs.
二十多年前,C++ 已经经历了第一阶段和第二阶段.因此很容易找到专门用于 C++ 的编译器的前端",并生成直接传递给支持的中间格式.但是您仍然可以找到在编译之前翻译成 C(作为中间格式)的 C++ 版本.
C++ has gone through phase 1 and phase 2 over two decades ago. So it is easy to find a `front end' of a compiler that is dedicated to C++ and generates an intermediate format that is passed directly to a backed. But you can still find versions of C++ that are translated into C (as an intermediate format) before being compiled.
这篇关于所有 C++ 编译器都生成 C 代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:所有 C++ 编译器都生成 C 代码吗?
				
        
 
            
        基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
 - 在 C++ 中计算滚动/移动平均值 2021-01-01
 - 常量变量在标题中不起作用 2021-01-01
 - 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
 - 这个宏可以转换成函数吗? 2022-01-01
 - 如何在 C++ 中初始化静态常量成员? 2022-01-01
 - 我有静态或动态 boost 库吗? 2021-01-01
 - 如何检查GTK+3.0中的小部件类型? 2022-11-30
 - 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
 - 如何通过C程序打开命令提示符Cmd 2022-12-09
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				