Which is the best C++ compiler? [closed]

2020-05-23 08:28发布

Can a C++ compiler produce a not so good binary? You can think here of the output's robustness and performance. Is there such a thing as the "best" C++ compiler to use? If not, what are the strong points, and of course, the not-so-strong (known Bugs and Issues) points, of the well-known compilers (g++, Intel C++ Compiler, Visual C++, etc.).

Are there documented cases when a compiler produced incorrect output which resulted in a failure of mission-critical software?

9条回答
可以哭但决不认输i
2楼-- · 2020-05-23 08:42

What is the platform you are using? For instance, Visual C++ will not be of use to you on Linux.

Actually, the three you mention are the three I'd have picked, for these reasons.

gcc/g++: open source, proven, refined by years of collaborative experience on many Linux and UNIX systems. The not-so-strong point is merely that it is a stand-alone command-line tool. You can make, or possibly find, your own IDE-style environment but it doesn't "ship" that way, so to speak.

Visual C++: well supported by Microsoft, loads of code samples and documentation (MSDN), naturally hooks into the Windows APIs. The not-so-strong point is that it's not especially, well, "visual." If you're used to Visual Basic (say) you'll find Visual C++ doesn't work the same way at all.

Intel C++ compiler: alas, I have no experience with Intel's compiler but I am lead to believe it supports parallelism and has high-precision numeric libraries.

Another maybe worth mentioning is Borland's C++Builder. It gets a plus for being a rapid application development environment with a wealth of add-on controls via compatibility with Delphi's VCL, but conversely code developed in C++Builder is not easily portable to other C++ compilers.

查看更多
够拽才男人
3楼-- · 2020-05-23 08:43

Since you mention "as part of a commercial airplane system" in a comment, it may be worthwhile looking at the compilers provided by companies that actually maintain certification in that space, or other safety-critical product spaces. Green Hills Software is one. Wind River is another.

查看更多
劳资没心,怎么记你
4楼-- · 2020-05-23 08:46

If you're talking about high performance of the output code in the High Performance Computing sense, you may also be interested in Portland Group's compilers and IBM's XL compilers.

查看更多
迷人小祖宗
5楼-- · 2020-05-23 08:48

http://www.compilers.net/Dir/Free/Compilers/CCpp.htm

Microsoft has a good free compiler, but if you're working on unix or mac that will do you little good.

Borland has a good free compiler as well.

I have tried out several free compilers and feel most comfortable with the Dev-C++. The total package is relatively small in size and comes in windows and linux flavors. For me it is perfect to test out the limits of the C++ language. It compiles fast and makes experimentation easy.

I recommend you this software called Digital Mars C/C++ Compiler,and you can get it from http://www.brothersoft.com/digital-mars-… it is a free C/C++ compiler for the for Win32, Win16, DOS32 and DOS environment.

查看更多
Luminary・发光体
6楼-- · 2020-05-23 08:50

I found problems using Cygwin, such code that doesn't compile but generates a segmentation fault inside the compiler. The same code works with MinGW.

[edit] Here is the compiler report:

lista.h: In constructor `Lista<Dado>::Lista() [with Dado = int]':
principal.cpp:15:   instantiated from here
lista.h:13: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://cygwin.com/problems.html> for instructions.

I don't have the source code that generated the error anymore, so I can't submit a report.

[/edit]

查看更多
Juvenile、少年°
7楼-- · 2020-05-23 08:55

G++ seems to be the most popular. It's free, portable and quite good. The Windows port (MinGW) was really dated the last time I used it (maybe one year ago).

The Intel C++ compiler is considered as the one which generates the fastest code (however it's known that it generates bad SIMD code for AMD processors). You can use it freely on GNU/Linux under quite restrictive conditions.
I've used it for some time and I liked the fact that it emits clever warnings which others don't.

VC++ is often regarded as the best C++ IDE, and from what I hear the compiler is quite good too. It's free (as in free beer), and only available on Windows of course.
If you are interested in Windows programming I would suggest this compiler, because it's always up-to-date and provides more advanced features for this purpose.

I would suggest VC++ on Windows, G++ for other OSes. Try the free version of I++ yourself, to see if it's worth the money.


Are there documented cases when a compiler produced incorrect output which resulted in a failure of mission-critical software?

Yes, probably, but I'd say that most of the time it's probably the programmer's fault. For example, if someone doesn't know how floating-point arithmetic works, it's easy to write unreliable code. A good programmer must also know what is guaranteed to work by the C++ standard and what isn't. She should also know what are the limits of the compiler, e.g. how well it implements the standard and how aggressively it optimizes.

查看更多
登录 后发表回答