简体   繁体   中英

Would C/C++ code compiling on Mingw guarantee full compatibility with GCC(on linux and Mac)

I'd like to produce cross-compiler compatible C++ code. I've produced a somewhat "exotic" code, that push the C++ language in its gray, weird, mysterious areas.

Considering my code only depends on boost and the STL, that the issue is to check code compatibility, and not lib compatibility:

Would my code compiling both msvc and Mingw ensures a 100% that my code is compatible with GCC on every platform?

Not at all.

Compiling your code with MSVC and MinGW guarantees that your code is compatible with Microsoft's C/C++ libraries. I understand you're only talking about code compatibility, but such a thing doesn't exist. If you're pushing C++ into the gray areas, it might well be that the same code will have different results depending on the platform you compile it on.

The best, and only way to guarantee full compatibility is compiling and testing it on both platforms.

Although using GCC with -std=c++0X -Wall -Wextra -pedantic (or any other std version) and getting rid of all the warnings will give a pretty good idea of code quality.

Honestly? To guarantee your code will compile with GCC on any platform is impossible. There is always that likelihood that something could be off, especially if you are doing 'exotic' things with your code.

您也可以尝试使用cygwin进行编译,这样可以更好地了解它将如何在更像Unix的系统上构建(尽管它仍然无法保证在所有系统上运行,但它比仅仅尝试msvc和MingW更好) Windows编译器)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM