Compiling C / C ++ code on Mingw guarantees full compatibility with GCC (on Linux and Mac)

I would like to create C ++ compatible code. I have produced some "exotic" code that pushes the C ++ language in its gray, strange, mysterious areas.

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

Will my code compile both msvc and Mingw, guarantee 100% that my code is compatible with GCC on each platform?

+4
source share
3 answers

Not at all.

Compiling your code using MSVC and MinGW ensures that your code is compatible with Microsoft C / C ++ libraries. As far as I understand, you are only talking about code compatibility, but such a thing does not exist. If you push C ++ to gray areas, it is quite possible that the same code will have different results depending on the platform on which you are compiling it.

The best and only way to guarantee full compatibility is to compile and test on both platforms.

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

+3
source

Fair? It is not possible to guarantee that your code will compile with GCC on any platform. There is always the possibility that something may be disabled, especially if you are doing β€œexotic” things with your code.

0
source

You can also try compiling with cygwin, which will give a better idea of ​​how it will be based on a more similar Unix system (although it still does not guarantee operation on all systems, it is better than just trying msvc and MingW, which both are just Windows compilers).

0
source

All Articles