The number of C++ compilers on the market has gone down in recent years. Several of the less known compilers have gone out of the market, and even the once so popular Borland (Embarcadero) C++ compiler is now no longer maintained. Compiler making has become more complicated with new advanced C++ standards (C++17, C++20), new instruction set extensions such as AVX512 with hundreds of new instructions, and higher standards for code optimization.



Microsoft Visual Studio is very popular because of the user friendly IDE and excellent debugging and cross-reference features. But Visual Studio is lagging behind on support for the latest instruction sets, and it is not the best compiler when it comes to code optimization.



The Intel compiler used to be on the cutting edge of code optimization, but now it has been overtaken by Gcc and Clang. Intel's compiler has also lost in popularity since its hidden "Cripple AMD" function was revealed.



The open source compilers Gcc and Clang have now taken the lead. These two compilers are very similar. Both are supporting all platforms and the newest instruction set extensions.



I have tested the different C++ compilers and listed the results in my C++ manual. The Gcc and Clang compilers are clearly the best when it comes to code optimization. Clang is better than Gcc in several respects, but it has a tendency for excessive loop unrolling, which is a waste of code cache. I must admit that I was quite skeptical of the LLVM/Clang project when it started, but people have put an impressive amount of work into it, and now the Clang compiler can outperform all other compilers on several measures.



Linux and Mac programmers will have no problems finding a Clang compiler. It is a little more complicated on Windows. There are at least two ready-to-use Clang compiler versions for Windows. A Cygwin version and a Visual Studio plugin version.



The Cygwin version of Clang has been around for several years, but it is not fully up to date and it has some performance problems. The Cygwin64 version of Clang is using a medium memory model by default. This is quite wasteful because it will use 64-bit absolute addresses rather than 32-bit relative addresses for static variables and constants. You can improve performance by specifying mcmodel=small. The medium memory model is needed only if you are making a direct link to a variable inside an external DLL (which is bad programming practice anyway). Another disadvantage of the Cygwin version is that you have to include the Cygwin DLL when distributing the executable.



Recently, Microsoft has made a Cygwin build available as a plugin to Visual Studio. My tests show that it produces excellently optimized code. The Cygwin plugin is not yet integrated into the MSBuild framework. It is only supported for the CMake framework, which is quite complicated to use because you have to manually specify a weird mix of Microsoft command line options and Clang options. In fact, I found it more convenient to use the Clang compiler as a command line tool without the Visual Studio CMake framework.



Microsoft have announced that a full integration of Clang into the MSBuild framework will be coming soon. Let's hope that they will deliver on this promise. We will look forward to perhaps the best optimizing compiler integrated to one of the most user friendly IDE frameworks.



On a longer horizon, I suspect that the Clang compiler will eventually replace Microsoft's own compiler. Why would they spend a lot of resources on developing a compiler when it is outperformed by a free and open source compiler anyway. The Visual Studio IDE may still be maintained because it is very useful and a lot or current projects depend on it, even if it will have a different compiler in the back end.



I am more uncertain about the future fate of the Intel compiler. Will they keep maintaining it when fewer and fewer programmers actually use it? There are some very useful function libraries for a lot of specialized purposes that come with the Intel compiler, but these function libraries are working just as well with other compilers.