在与海湾合作委员会与G连接任何区别++? [英] Any difference in linking with gcc vs. g++?

查看:128
本文介绍了在与海湾合作委员会与G连接任何区别++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有链接过程的gcc和g之间的差异++?

Are there any differences in the linking process between gcc and g++?

我有一个大C项目,我刚换了code的一部分,C ++。在code未使用std C ++库还,所以 -llibstdc ++ 不需要现在。

I have a big C project and I just switched part of the code to C++. The code isn't using std C++ library yet, so -llibstdc++ isn't needed for now.

推荐答案

的主要区别是,(假设文件被检测为C ++)G ++设置需要与C ++标准库链接的标志。它也可以设置例外处理。我不会依赖,仅仅因为你的应用程序不使用时为C编译它并不需要标准库的事实++(例如默认的异常处理程序)。

The main difference is that (assuming the files are detected as C++) g++ sets up the flags needed for linking with the C++ standard library. It may also set up exception handling. I wouldn't rely on the fact that just because your application doesn't use the standard library that it isn't needed when compiled as C++ (for example the default exception handler).

编辑:正如在评论中指出要你跟任何构造的麻烦(即做的工作)的静态对象以及没有得到虚函数表(所以如果你正在使用C的这些功能​​++你仍然需要链接该库)。

As pointed out in comments you'll have trouble with any constructors (that do work) for static objects as well as not getting virtual function tables (so if you're using those features of C++ you still need to link that library).

EDIT2:除非你使用的C99指定code在C项目中,我实际上只需切换到编译整个事情的C ++在迁移过程中的第一步

Unless you're using C99 specific code in your C project I would actually just switch to compiling the whole thing as C++ as the first step in your migration process.

这篇关于在与海湾合作委员会与G连接任何区别++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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