In trying to evaluate Clang on Windows, utilizing the Windows Universal C Run-Time (...\Windows Kits\10\Include\10.0.15063.0\ucrt) I was immediately facing unexpected wall, in the form of an undisclosed and unexpected dependency on Microsoft's Visual Studio. Apparently even the simplest C program will not be able to compile as soon as you include any standard C header, because they all seem to end-up attempting to #include vcruntime.h (which is not part of the UCRT).
My questions are:
- Is there a way to utilize the Windows Universal C RTL SDK withOUT Visual Studio?
- If it is not intended or possible, why then is it not called "Windows CRT for Microsoft VC" - what am I missing?
Check out [MSDN]: Introducing the Universal CRT (and also the other URLs that it references):
From [MSDN]: The Great C Runtime (CRT) Refactoring (to clear things up about (some of) the bold items):
According to [MS.Support]: Update for Universal C Runtime in Windows:
and from [MS.Dev]: Windows 10 SDK:
So, UCRT is strictly bound to VStudio. Universal: means that it's not dependent on VStudio version (all VStudio versions will use a common one (there can be only one)).
UCRT is the Win (wannabe) equivalent of Ux's libc.
I took a look in SDK include dir (e.g. "c:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt"):
#include <corecrt.h>
#include <vcruntime.h>
no
#ifdef
s, so there is no way (at least no easy one) to overcome this.But, things are even clearer when reaching link phase. If your C code includes UCRT headers, it will (most likely) link to files from SDK lib dir (e.g. "c:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x64"), which are generated by VStudio, and there's a great chance for that to fail. Example:
code.c:
The 2 (generated) files are incompatible:
Now, I know that lld (I remember that I built it in the past, but I can't find it, in order to test my statement) is able to link both ELF and COFF file formats, but I doubt that it can combine them.
Conclusion
Based on the above, here are the answers to your questions:
I suppose it is - an unsupported one though (claiming that something is impossible is almost always false). But, there would be lots of restrictions (consider the above file format matching), and would most likely require some dirty tricks or workarounds (gainarii) like (some that I can think of now):
#include
s)Adding VStudio (or anything else, as a matter of fact) in the name would automatically decrease its "universality level".
And this is only the 1st step: it has been separated from VC Runtime. Think of it as of a baby. In time, it will become mature and (more stable) and maybe other compilers / build toolchains will end up supporting it (no need to follow the spartan rules, and throw it off the cliff :) ... at least not right now).
But, I think only MS could have an answer to this (although there's a great chance that they won't provide a clearer one)
I live in a country with a television network called Global. For the first 15 years of Globals existence, you could only watch it if you lived in a one city, Toronto. Yet, it was Global. Microsoft has a similar definition of Universal.
In the real programming world, there is a better definition of universal, it is called UNIX. Even Microsoft has been forced to (pretend to) understand UNIX; and Linux definitely understands UNIX. You don’t have to put up with shitty development tools; Linux and UNIX are available everywhere.