13

I have read some questions about GCC vs MSVC and the development of these compilers such as GCC worth using on Windows to replace MSVC?, Visual Studio or GCC? and GCC vs MS C++ compiler for maintaining API backwards binary compatibility. But those are very outdated questions(2011). With new c++14 features coming things are starting to balance between the two compilers. Is it still worth using Code::Blocks on Windows with all the advantages of using Microsoft Visual Studio such as:

  • Native Windows libraries with support to using MFC, ATL, DirectX and other useful Microsoft libraries.
  • Great debugging features, especially when using the disassembly view(it has so many useful features).

In most of the topics I have read, they always say GCC code generation was better than MSVC's, but the differences in that matter were starting to narrow. Is code generation still better in GCC? What about newest c++ features, which of them is ahead?

The biggest advantage I see in using GCC versus MSVC is that:

  • It is open source, which makes custom compiler code possible.
  • Easier to make portable code.
  • IT IS FREE.
  • ???Better code generation???

C++14 features on GCC: https://gcc.gnu.org/projects/cxx1y.html

C++11 and C++14 features on MSVC RTM: http://blogs.msdn.com/b/vcblog/archive/2015/06/19/c-11-14-17-features-in-vs-2015-rtm.aspx

Community
  • 1
  • 1
Nighteen
  • 731
  • 1
  • 7
  • 16
  • 5
    MFC sucks, ATL is a dinosaur. It seems to me that the MS compiler is still too far behind, although they have announced that an upcoming version of VS will support clang++ . – M.M Jul 21 '15 at 02:23
  • g++ for Windows does have its plusses and minuses. One big minus is that you can't really use boost because it is too slow without precompiled headers, and the compiler crashes if you do use PCH because the PCH file is too big (over 600MB for 64-bit). – M.M Jul 21 '15 at 02:24
  • 3
    I'm sure this will be closed as opinion-based any time now, although personally I'd like to see various opinions from people who have used both tools and compared – M.M Jul 21 '15 at 02:25
  • 2
    _DirectX and other useful Microsoft libraries_ are supported by MinGW too. Please do enough research on such opinion-based questions and make a call for yourself; a more objective question would perhaps benefit the community better. Also most of these things depend on what project you have in mind. You don't need all of MFC, ATL, DirectX, just some subset / combination, which shows this is just a show-of-strength question. – legends2k Jul 21 '15 at 02:30
  • If you ask me, code generation is way better in llvm in comparison with gcc. And you can integrate clang/llvm with VS so you can have the best of both worlds. VS generated code is good nowdays so you might not even see any difference in performance. – Pedrom Jul 21 '15 at 02:30
  • g++ has the advantage of being free too. (MSVC Community Edition exists but I'm not sure what its feature set is) – M.M Jul 21 '15 at 02:32
  • @legends2k Yes I know there is support, but not as easy to use as in MSVC. Still, OpenGL is better in my opinion. – Nighteen Jul 21 '15 at 02:32
  • @MattMcNabb I agree... I wish they would be more flexible with that, these kind of experience, war stories telling questions are of good value – Pedrom Jul 21 '15 at 02:33
  • 1
    IMO, the biggest issue with g++ is that it relies on glibc, and the glibc devs don't give two hoots about Windows. This is why it took years and years to fix things like `std::to_string`. You still have to use a hack to use `std::thread` and related. So library conformance is an ongoing issue. – M.M Jul 21 '15 at 02:33
  • @user2565020 Easy perhaps because of the IDE, but isn't comparing a compiler and an IDE wrong? A fair comparison would be between g++ and cl (the VC++ compiler) (or) some IDE and VS. – legends2k Jul 21 '15 at 02:34
  • 1
    @MattMcNabb MSVC Community edition has the same compiler than the enterprise edition. The difference is just in the IDE feature set – Pedrom Jul 21 '15 at 02:35
  • 2
    gcc has way better C support than MSVC. This can be important if working with C libraries. In fact, not until recently could you compile ffmpeg with MSVC. Nowadays you can, but there are still other projects out there that use C features that MSVC just doesn't have (nor does it intend to have any time soon). While this is about C++, it's not uncommon to use C projects inside of a larger C++ project, so I think it's worth mentioning. – Cornstalks Jul 21 '15 at 02:35
  • @legends2k Agreed, it is pretty unfair, but when you use MSVC you are almost always automatically using Microsoft Visual Studio, that is why I used that information in the question. That isn't true for GCC, there are a lot of IDEs people use, I prefer Code::Blocks. – Nighteen Jul 21 '15 at 02:38
  • @Pedrom what about available headers and libraries though? Can you build COM objects, WPF apps etc. in community for example? – M.M Jul 21 '15 at 02:40
  • 1
    Visual Studio Community is fully featured. This is in contrast to Visual Studio Express, their previous free version. Express was free to use for any purpose, including commercial applications in a large company, but it had a limited set of features. Community is a full version of Visual Studio, but is limited to personal use, or commercial use with small companies (less than 5 computers, I think?). I don't have a stake in the argument, but for the majority of people inquiring about personal use, it's as free as gcc – mock_blatt Jul 21 '15 at 02:51
  • @mock_blatt But the limited features still bug me. – Nighteen Jul 21 '15 at 02:55
  • That link is very outdated. The right one to look at is [C++11/14/17 Features In VS 2015 RTM](http://blogs.msdn.com/b/vcblog/archive/2015/06/19/c-11-14-17-features-in-vs-2015-rtm.aspx) – Chuck Walbourn Jul 21 '15 at 04:23
  • @ChuckWalbourn Thanks, fixed the outdated link. – Nighteen Jul 21 '15 at 05:53

2 Answers2

11

Yes.

Although MSVC has made some progress toward newer C++ standards, it is still woefully behind, even on C++98 status (which is conveniently excluded from that status page).

From what I've read recently, the MSVC team does not even have a concrete plan for fixing some of the old issues, e.g. with name lookup and template instantiation.

Now, when you can use MSVC with clang as the compiler, that might be reason to stop using GCC. However, for my purposes, I find that clang has much inferior diagnostics (and sometimes inferior code) so I still use GCC as my primary compiler and just use clang as a backup.

And as @Cheersandhth says, it's good to use two compilers. Though maybe look at Intel's compiler.

o11c
  • 15,265
  • 4
  • 50
  • 75
  • So, is code generation still better in GCC? – Nighteen Jul 21 '15 at 02:51
  • 3
    @user2565020: It can be. For my raytracer, GCC was definitely better than clang and MSVC (GCC code was about 10% faster). But other programs might favor clang's (or MSVC's) optimizer and code generator. – Cornstalks Jul 21 '15 at 03:00
  • Which version of VS are you talking about when you say "some progress"? – Chuck Walbourn Jul 21 '15 at 04:24
  • There was quite a lot of Code that I could not compile with GCC in Windows, trying both shitty MinGW and shitty MinGW-w64 for that matter. It compiles with Linux and GCC, and it compiles with MSVC. GCC on Windows is just unusable cancer because the oh-so-smart Open source Community actually gives a shit about portability, as long as it works on Linux – clocktown Feb 10 '17 at 17:53
  • 1
    @clocktown you should look into [MSYS2](http://www.msys2.org/) (not MSYS). – bit2shift May 23 '17 at 20:04
  • @bit2shift That's what I was talking about. It's probably the best you will get with GCC on Windows and it still sucks. – clocktown May 24 '17 at 20:55
  • @clocktown That's why I took the plunge and compiled GCC 7.1.1 in MSYS2, which isn't available yet through pacman. Had some trouble at first, but managed to get through. – bit2shift May 25 '17 at 16:21
  • Is this relevant even today? – Vasantha Ganesh Jul 07 '20 at 05:16
  • 1
    @VasanthaGaneshK MSVC has made some very impressive strides since this post. Mind, I don't have personal experience. I still prefer the ecosystem of GCC (portable, extensions, plugin API). – o11c Jul 08 '20 at 01:38
10

The elaborated question is an open invitation to opinions; there's even some provocation about "best IDE" etc. Even so the question as posed in the title,

C++ - Is GCC [i.e. g++] worth using on Windows nowadays?

has a simple fact-based answer, namely yes, because

  • it's a good idea to expose code to at least two compilers, when that's possible, e.g. the combo Visual C++ and g++, and

  • g++ is good for purposes of learning.

The main problem with g++ in Windows is that its API binding only covers the Windows XP API fully, and nothing very little after.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331