I want to use it because it says it supports all the C++11 features and I'm hoping that includes Regex as well since gcc isn't near finishing anytime soon..

However, many other websites are saying that clang requires Mingw/gcc to be used in the first place. It doesn't make any sense to me that a compiler requires another compiler and the other compiler's headers to be used. And that I have to build it using gcc as well :S

The clang website also says I need to specify the path to my gcc/mingw headers. :l

So my question is: Does anyone here use Clang on Windows to compile C++? If so, does it have to use the gcc/mingw headers and compiler? I installed CodeLite IDE for clang because I'm not sure that it'll work with codeblocks but I haven't installed clang yet because of this hesitation. I'm not sure I want to use a compiler that depends on another compiler. Anyone?

From what I read I think Clang is just an IDE, but the description is somewhat confusing. The description calls it a front end in some places, meaning just an IDE, and a compiler in other places. It also says it's still under development, so it might not be very useful to anyone other than people who like to write compilers. If all you want to use it for is supprot for Regex you can get that with the Boost libraries.

@AD: Let me clear that cloud of confusion. Clang is the C / C++ / Objective-C / Objective-C++ front-end for the LLVM compiler back-end. It is a GCC-compatible compiler suite (i.e., you can usually replace any clang-llvm tool with a GCC one, like the linker or standard libraries). Clang is purely a compiler suite, exactly like GCC. It can generally be used as a drop-in replacement for GCC (only the very advanced options differ). It has been mainly supported by Apple and Google, and it is the main official compiler for Mac platforms (for all languages mentioned).

@triumphost:
The Windows support by Clang is only experimental at this point. This means no binary distributions (have to compile from source), no guarantees, no help.

One option is, of course, to use Cygwin. Cygwin is basically a unix system running inside a command-line interface in Windows, which means it is a unix system, and clang is supported, and is even distributed as a standard package (but not the last version) in cygwin's package manager. If you want the newer version, you'll have to compile it from source, which will require either GCC or an older Clang version installed in Cygwin. For doing this, you should just follow the Unix/Linux instructions, because Cygwin is no different. But this also means that you are not really in Windows, and the programs you compile will be compiling for Cygwin, not Windows (Cygwin does have a run-time distribution that allows you to distribute cygwin-compiled programs as windows programs, and many Windows ports of Unix/Linux software are just that, for example, the Windows version of Git).

But for a more "native" compiler, you'll have to use MinGW. You seem to be a bit confused about what MinGW is. MinGW is not the compiler (GCC), it is the environment (set of tools and libraries) that allows GCC to work in Windows. The same environment is needed to make Clang work too (i.e., as I said, a drop-in replacement for GCC). The environment consists of MSYS (the command-line tool), GNU binutils (for reading / writing binaries (executables / libraries)), some libraries to link with system libraries, and GNU's C++ standard library (libstdc++). If you want advanced features like regex, you'll have to switch the standard library to LLVM's implementation of it, which is libc++, that's going to be an additional piece of trouble (I believe, maybe even insurmountable).

The reason why you need GCC (in MinGW), is because you need a compiler to compile LLVM and Clang from the source code. And obviously, there are not that many options (of compilers) in Windows, and the Microsoft compiler (MSVC) is clearly out of the question (I doubt anyone in the LLVM/Clang team will ever go through the trouble of supporting such a quirky compiler). Generally, the way a compiler is compiled is a process called "bootstrapping", which means that you first start with some other compiler that you use to compile the source code, and then you take the compiler that you just created and use it to compile the source code again, and then again (usually, no more than three times). This is to ensure correctness and optimal performance of the final compiler.

There are three main parts here: LLVM (back-end), Clang (front-end), and the standard library. I believe that compiling LLVM and Clang in MinGW should not be too big of a problem (as far as I could tell, but I never tried). But that is still just a replacement for GCC, i.e., only the compiler, linker and associated tools. The standard library is another separate part, and if you want the regex library, then you will need the LLVM implementation of the standard library, which is called libc++. And sadly, it does not work on Windows. So, in other words, there is no point in even going through the process of compiling Clang if all you want is the regex library, because that is in the realm of libc++ which is not supported for Windows. The only standard library that Clang can use in Windows is GNU's implementation of it (that comes bundled with MinGW), which is called libstdc++, and it is missing the regex library (a glaring omission!). So, as AD said, you'll have to fall back to Boost.Regex.

And at this point, the C++11 support in GCC is complete, as complete as the latest Clang versions, so the benefits of trying to get Clang working on Windows, as opposed to going for bleeding-edge MinGW (or TDM-GCC) distributions, is probably not worth it.

commented: Is there anything you don't know? +14

Aww.. I was so excited when I saw every feature checked off and that it even had some C++14/C++ly features.. I have boost. I just wanted some standard support without external libraries and such and I came across clang. Ah I'll just stick to gcc then.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.