用C ++编译器编译C程序的成本是多少? [英] What is the cost of compiling a C program with a C++ compiler?

查看:105
本文介绍了用C ++编译器编译C程序的成本是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在嵌入式环境中使用带有模板的C,并且想知道用C ++编译器编译C程序的成本是多少?

I want to use C with templates on a embedded environment and I wanted to know what is the cost of compiling a C program with a C++ compiler?

我想知道是否有比C编译器生成的代码更多的代码。

I'm interested in knowing if there will be more code than the one the C compiler will generate.

请注意,由于该程序是C程序,因此希望在无异常和RTTI支持的情况下调用C ++编译器。

Note that as the program is a C program, is expect to call the C++ compiler without exception and RTTI support.

感谢,
Vicente

Thanks, Vicente

推荐答案

假设两个编译器的质量相同,则可能没有成本。传统的反对意见是C ++要复杂得多,因此C ++编译器很有可能会在其中包含错误。

There's probably no 'cost', assuming that the two compilers are of equivalent quality. The traditional objection to this is that C++ is much more complex and so it's more likely that a C++ compiler will have bugs in it.

实际上,这已经不再是以前的问题了,我现在倾向于将大多数嵌入式工作作为一种可怕的C / C ++混合体来进行。 -利用更强大的输入和更简单的变量声明规则,而不会产生RTTI或异常处理开销。如果您要使用给定的编译器(GCC等)并将其从C切换到C ++模式,那么无论如何,这两种语言都需要担心的很多事情。

Realistically, this is much less of a problem that it used to be, and I tend to do most of my embedded stuff now as a sort of horrible C/C++ hybrid - taking advantage of stronger typing and easier variable declaration rules, without incurring RTTI or exception handling overheads. If you're taking a given compiler (GCC, etc) and switching it from C to C++ mode, then much of what you have to worry about is common to the two languages anyway.

这篇关于用C ++编译器编译C程序的成本是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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