4 ms·
Microsoft, please support (at least a tiny bit of) C99
- TwoBit 15y agoWhen discussing this topic, people like to say that C is more commonly used that C++. But I think that the reality is that -Microsoft's customers- use C++ much more than C. I am such a customer and in my field 95% or more of programming is C++. I still wish they would support a few very basic C99 features though.
- archangel_one 15y agoI think there might be a bit more than people realise - for example, the last company I worked for did primarily C++ Windows applications, but we had several third-party C libraries built in as well (Python, GDAL, proj, etc) which we needed to be able to build in VC++. Presumably this kind of use case is exactly the sort of thing which would prevent libraries like Python from moving on to use C99 features. I definitely agree that it would be much better if MS just supported those few features, which frankly don't seem that hard in the scheme of things. Makes me think that they see some advantage to them in not supporting it, although I'm not sure what that'd actually be.
- apaprocki 15y agoYes, a few of the libraries I've been involved with do not want to allow C99 features into the codebase because of MSVC. This, IMO, is the main reason for wanting some C99 in MSVC -- to stop Windows from holding the rest of OSS hostage when it comes to more modern language features.
- raldi 15y agoWhat are "for loop initial decorations"?
- mvzink 15y agofor (int i = 0; i < n; i++) { ... } instead of int i; for (i = 0; i < n; i++) { ... }
- TheNewAndy 15y agoI suspect that C11 support is closer than C99 support (and it would be good too). Things like variable length arrays are now optional.
- cygx 15y agoThere are exactly 2 features which were mandatory in C99 and are optional in C11: variable-length arrays and complex types. C11 adds some non-optional features whch needs compiler support (alignment specifiers, type-generic selections, unicode literals, ...). Do you really think vendors which don' care about C99 will suddenly jump to implement all mandatory C11 features?
- BudVVeezer 15y agoSince it means not having to support VLAs, yes.
- nknight 15y agoOne is not obligated to support all features of a standard in order to support some, a reality Microsoft has consistently availed itself of during its existence.
- BudVVeezer 15y agoSo by your standards, Microsoft is doing quite well. After all, they do support parts of C99 such as stdint.h.
- nknight 15y agoYou really have no idea what my standards are. All I did was say they didn't have to support VLAs to support other parts of C99. That tells you absolutely nothing, stop assuming so much.
- deleted 15y ago[deleted]
- haberman 15y agoArticle author here. If you have similar pain, you can show your support for this here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2089423-c99-support http://visualstudio.uservoice.com/forums/121579-visual-studi... I know this is probably a losing battle, but I feel better at least being able to express my displeasure about the issue.
- eliben 15y agoVoted. Thanks for doing this!
- saurik 15y agoThe stdint.h header comes with MSVC 2010.
- chj 15y agoDo not beg. Do not use it.
- batista 15y agoYes. And do the same with everything you want to use but doesn't have a feature you can't add yourself* --see how far that will get you. (*) e.g because you don't know how to do so, you're not good enough to program it, the main maintainers don't agree or because the source is closed.
- buster 15y agoIt's not that there are no alternatives.. http://gcc.gnu.org/ http://gcc.gnu.org/ http://clang.llvm.org/ http://clang.llvm.org/ http://software.intel.com/en-us/intel-sdp-home/ http://software.intel.com/en-us/intel-sdp-home/ http://www.pathscale.com/ekopath-compiler-suite http://www.pathscale.com/ekopath-compiler-suite
- rwmj 15y agoThe reason given when this same article was discussed on reddit was that library authors need to use the same compiler as their customers. In other words, a GCC-compiled Windows DLL is not a drop-in replacement for a MSVC-compiled DLL. I'm sure this is true for C++ which has a crazily complex ABI for things like classes and exceptions. But is this really the case for plain C? (not in the Linux world AFAIK)
- apaprocki 15y agoJust as a comparison, I've heard that Oracle will most likely adopt GCC's C11 ABI when C11 support is added so that one actually will be able to mix-and-match objects from both compilers.
- DarkShikari 15y agox264 has worked fine in many many MSVC applications, even compiled in minGW with gcc. There are some minor catches: 1. If you want a .lib instead of a .dll, you have to make one yourself separately using a tool. Not a big deal, it's just that gcc does do it for you. 2. No debug symbols, because MSVC doesn't support DWARF/etc. 3. gcc guarantees 16-byte stack alignment on x86_32, but only with respect to the caller; MSVC does not, so the stack may not be aligned as gcc expects it. You can use -mpreferred-stack-boundary to make gcc expect it, or you can just explicitly align the stack, either with the gcc intrinsic (requires ~gcc 4.2) or a small assembly function. There are probably a few others, but overall, it does work; cdecl is cdecl.
- 4ad 15y agoC works fine, I even toyed with a kernel module build using MinGW instead of the WDK. One caveat is that GCC doesn't generate PDB information, the debugging format used by Microsoft tools. Only C++ doesn't work.
- AshleysBrain 15y agoDoesn't Microsoft have a disincentive to support it here? It would encourage people to use open-source alternatives to The Microsoft Way.
- CurtHagenlocher 15y agoThe same thing could be described as a disincentive for supporting more-recent C++, and yet Microsoft is implementing those features at a pace which is unusually fast (for VC). I'm sure the real issue is much more prosaic: it costs money to implement, and it's not something that most of VC's customers are asking for. The expense here probably isn't in changing the compiler itself; it's in the implementation of the test suites. And while there may be open source test suites available under an acceptable license, the company's willingness to make use of outside source is changing at a glacially-slow pace -- particularly for core products. Disclaimer: I work at Microsoft and know some people on the C++ compiler team. These comments are purely speculative on my part.
- AshleysBrain 15y agoI don't think there's a disincentive on the C++ side - the best Windows apps use C++ so improving C++ helps make Windows a strong platform. The article also points out many of the most missed features of C99 are straightforward, and hopefully the tests would be too.
- Zarathust 15y agoSurely Windows must use tons of C. I wonder what compiler internal devs are using. Archaic support of C seems more like a tactical choice than a laziness one in that case
- zokier 15y agoIt's probably all C++ -clean, so they can compile everything as C++.
- 4ad 15y agoNo, you use whatever you want, in practice C is more used than C++ and C code is compiled with the C compiler, not C++ compiler. The tools used to build Windows, including compilers, are available as the free Windows Driver Kit (WDK): http://msdn.microsoft.com/en-us/windows/hardware/gg487428 http://msdn.microsoft.com/en-us/windows/hardware/gg487428 Sometimes the compiler versions match those of the current Visual Studio release, but not always.
- njs12345 15y agoMaybe they've switched to using a C++ compiler and C linkage specifications..