MS与非MS C ++编译器兼容性 [英] MS vs Non-MS C++ compiler compatibility

查看:159
本文介绍了MS与非MS C ++编译器兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑在Windows上使用MinGW替代VC ++,但担心兼容性问题。我在思考的行为,在Windows上的性能(任何机会,MinGW编译EXE可能会起作用)。此外,在调用Windows API,第三方DLL,生成和使用兼容的静态库以及使用两个编译器混合相同应用程序的其他问题时遇到的其他问题。

解决方案

首先,MinGW不是一个编译器,而是一个环境,它与gcc捆绑在一起。



使用 gcc 来编译代码并让它调用Windows API,它是好的,因为它是C;但是对于MSVC生成的C ++ DLL,可能会有一个严重的唤醒调用。



主要的问题是在C ++中,每个编译器都有自己的名称更一般的ABI)和自己的标准库。您不能混合使用两个不同的ABI或两个不同的标准库。



Clang试图尽可能符合MSVC标准,但尚未开始。




  • 它成功地解析了MSVC标准库(2008和2010)以及MFC头,但是我不确定CodeGen方面。

  • 关于结构化异常的ABI问题,我认为它与专利问题有关,阻止他们并入Clang,但可能是错误的。



因此,你必须选择一个C ++编译器并坚持下去。



显然,你也可以简单地做交叉DLL通信

:Kerrek的澄清


Thinking of using MinGW as an alternative to VC++ on Windows, but am worried about compatibility issues. I am thinking in terms of behaviour, performance on Windows (any chance a MinGW compiled EXE might act up). Also, in terms of calling the Windows API, third-party DLLs, generatic and using compatible static libraries, and other issues encountered with mixing parts of the same application with the two compilers.

解决方案

First, MinGW is not a compiler, but an environment, it is bundled with gcc.

If you think of using gcc to compile code and have it call the Windows API, it's okay as it's C; but for C++ DLLs generated by MSVC, you might have a harsh wake-up call.

The main issue is that in C++, each compiler has its own name mangling (or more generally ABI) and its own Standard library. You cannot mix two different ABI or two different Standard Libraries. End of the story.

Clang is trying to be as MSVC compliant as possible, but is not there yet.

  • It succesfully parses the MSVC Standard library (2008 and 2010) as well as MFC headers, I am unsure about the CodeGen aspect though.
  • There is an ABI issue with regard to Structured Exceptions, I think that it has to do with patent issues preventing their incorporation into Clang, but may well be wrong.

Therefore you must choose one C++ compiler and stick to it.

Obviously, you could also simply do the cross-DLL communication in C to circumvent the issue.

EDIT: Kerrek's clarification.

这篇关于MS与非MS C ++编译器兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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