Friday, March 2, 2012

Microsoft, please support (at least a tiny bit of) C99

I'm afraid this plea will be mostly futile, but I just have to get it out. Microsoft, please support (at least a tiny bit of) C99.

Though it may seem strange, there are still a lot of us writing in C (and not C++), particularly in the open-source world. For example, all of the following very important open-source projects (which all are portable to Windows) are written either partially or entirely in plain C:

  • almost every open-source language VM (eg. Python, Lua, LuaJIT, Ruby, Perl, PHP, Erlang, R, Guile)

  • numerous very powerful software libraries (eg. zlib, sqlite, libmad, ffmpeg/libavcodec, x264, libsndfile, libsamplerate, gmp, fftw, libxml2, FreeType, libjpeg, libpng; this list is just the tip of the iceberg, there are way too many to list).

  • numerous apps/tools/servers (eg. Apache, nginx, vim, emacs, MySQL, PostgreSQL)

The reason you offer for not adding C99 support is
Hi: unfortunately the overwhelming feadback we get from the majority of our users is that they would prefer that we focus on C++-0x instead of on C-99. We have "cherry-picked" certain popular C-99 features (variadic macros, long long) but beyond this we are unlikely to do much more in the C-99 space (at least in the short-term).
It may be that we C users are in the vast minority. But considering that we have been offering free, high-quality software that enhances the usefulness of the Windows platform for both users and developers, couldn't you help make our job just a little easier by implementing even these most basic C99 features?

  • stdint.h and inttypes.h. Someone else has already done the work for you and released it under a permissive license (stdint.h and inttypes.h). Can't you just download these files and use them?

  • declaring variables in the middle of a block. Your C++ compiler can already do this, surely it wouldn't be too much work to update the C parser to support this?

  • 'for' loop initial declarations. This is also supported in C++ already.

If I was feeling really lucky I might even ask for designated initializers, but I don't want to push my luck.

Every other popular C compiler supports these features, which means that for many projects MSVC's lack of C99 support is the single gating factor keeping us from taking advantage of features that were standardized almost 15 years ago. Think about this: a large and diverse project like Python which might have tens of committers and run on lots of platforms is tethered to an almost 25-year-old language standard (C89) because one single compiler that is written by one of the world's largest software companies (with over 90,000 employees) can't find the time to do what every other compiler vendor has already done.

As I was researching this article I discovered that the /TP option will make MSVC compile C as if it were C++, which may give me enough of a workaround (albeit hacky) to get the above features that I most sorely miss. I still wish Microsoft would give us cross-platform developers even the slightest tip of the hat to help us out with bringing free, high-quality software to their platform.


  1. MS doesn't want FOSS on their platform, don't you get it ?
    The likelihood of them helping the developers of their competitors is zero.
    Is the history of how Microsoft operates unknown to you ?

    1. Interesting, zlib is one of the FOSS programs listed above and Microsoft itself has adopted that as an integral part of .NET. It ships in .NET 4.5.

    2. This comment has been removed by the author.

  2. IIRC, C is still more used than C++ (and likely to carry on that way), though I don't use it much myself.

    The trouble is, I suspect, that MSVC really isn't the compiler for the Windows platform. It's a very very good compiler, IDE etc for quite a large target group of Windows platform users, but not for everyone. With all the support for .NET, various APIs etc, even C++ isn't the primary thing for MSVC, though it of course remains important.

    MinGW GCC is a good compiler, though there's an issue with debuggers and other tools. Probably Clang is the future, though complete and reliable support for Windows doesn't seem to be a top priority, and it'll be a while yet before the promise of powerful tools based on Clang code is fully realised.

    As a last resort, I guess you could use Linux in a virtual machine, cross-compiling for the final builds. If Linux became the preferred IDE for developing in C for Windows, it would probably get Microsofts attention.

  3. Microsoft's support for C++ is purely tactical. Plus it is much closer to their C# world as well.

    They have no need for C and why would they want to support a business model that gives them no money?

    I think what would be more important is to offer a true open-source alternative to something similar to .NET in the *nix world.

    1. Do you not consider Mono ( to a true open-source alternative to .NET? Considering the amount of actual Microsoft authored .NET code it ships with (ASP.NET MVC, MEF, F#, the DLR, IronPython, IronRuby) it is increasingly identical rather than similar.

      What about Java? It seems pretty similar. With the recent Oracle ruling their should be a lot less concern about using it. With languages like Kotlin and Stab it is a pretty natural fit for people that like C#.

  4. Yes, this is basically futile. Blog posts aren't going to make Microsoft change their minds.

    What you actually need to do to make them listen is to give MSVC the IE6 treatment. Just drop support for it until it catches up.

    Microsoft is not going to listen until their lack of C99 support actually becomes a problem for people. And as long as we are going out of our way to not make the lack of C99 in MSVC a problem, nothing will happen. If nobody uses C99, Microsoft will not support C99.

    So there is only one way forward: Start writing C99, and if that leads to problems, tell people to take it up with Microsoft, and point them to gcc or clang in the meanwhile. Only when people stop being able to use the code they rely on in MSVC, and start complaining about this to Microsoft, will anything happen.

  5. Quality software is seldom written to a standard of "it compiles". If MSVC's C99 support grew but not to try actually to meet the C99 standard, I think very little quality software would want to try to target that. Software developers are notoriously finnicky, and "well, we support the subset of C99 that MS will let us" does not really meet that requirement.

  6. This may seem ridiculous, but the reason I don't use declarations in for loops on my small personal projects in Linux is because I don't feel like putting -std=c99 in the command line. Variable declarations in for loops are things that can easily be avoided, so I avoid them and never have to bother with that little command line argument. Obviously you wouldn't be manually typing in compile commands with any reasonably sized project, but avoiding this specific feature means that I never have a problem when I type gcc -o test test.c on any computer I regularly use.

  7. Even those of us that do C++ programming would enjoy having a compliant C99 compiler. There are a great number of things that C++11 has taken from C99 (or earlier C++ standards). Plus being able to work with C source files is often convenient.

    Any excuse provided by Microsoft not to support C99 is really just lame. There is no possibility that if you can provide a C++11 compiler that you can't quite easily provide a C99 compiler.

  8. The idea it's straightforward for them to add extant C++ features to the C compiler is predicated on the assumption that the front-end C and C++ compilers have a lot of code in common.

    But (having not seen their code, obviously) it's quite easy to imagine the two are quite disjoint. That is, they coded a fresh C++ front end but were too fearful of introducing subtle bugs into a well-tested product that they don't let the C++ system generate C code at all - but that instead they stick with the old C codebase.

    If that's the case (and naturally I'm just guessing) then they may be left in the position where the people who really understand the C subsystem have mostly left or moved to other projects, leaving them with a tulgey morass that the line engineers don't really totally understand.

    Big companies can be very risk averse (because they've got something to lose) and the risk of bad publicity gained from a small change to the C compiler unexpectedly breaking stuff they hadn't anticipated may weight more with them than the bad publicity they get from not implementing C99.

  9. On Windows the only thing you can make now are .NET applications. So when I want to just do C (Win32) I use GCC Mingw or on some company based stuff I use MSVC 6 which is no longer supported but works just fine. Microsoft just does not care enough about it.

  10. Which C99 features are really worthwhile in terms of increasing the languages expressive power?

    I often wonder why C programmers do not use a safe subset of C++.
    The majority of programmers need to support at most g++ and MSVC, and I dare say the language subset supported by both is pretty well defined.

    Why insist on C in this day and age? I would claim that any piece of code that you write in C that is not meant for an embedded system, can be written more cleanly, safely and as (or more) efficiently in C++

  11. [...] [...]

  12. @Vivek >I would claim that any piece of code that you write in C that is not meant for an embedded system, can be written more cleanly, safely and as (or more) efficiently in C++

    Sorry that I have to bust you out of your comfort zone.
    I'm "sure" you can prove your claim.. come on and show it.
    Let me explain you it this way, a language that is extending another language can't be any faster/safer/cleaner or more efficient than the language it is extending. Sounds reasonable? No? Take the alphabet, try to make it faster/safer/cleaner by extending it. return EXIT_SUCCESS?

    >"Why insist on C in this day and age?"
    Insisting in writing C, that what you use to label C Developers, it's not a good base for a discussion and no one in here insists on using Language X. Your next claim is that C is outdated because it is old. What you totally miss in your flawed argumentation is that people don't choose "C89 / C99" because it is cool/popular or new. You have totally missed the reasoning behind why someone wants to write a routine or a program in C.

    Please consider nex time that people who look like they insist in using something, might in reality have a reason why they think it makes sense. Ask for the reason instead of falsifying someone before starting a valid argumentation, that will make you a better person and understand views other than yours. It's not solely about tolerance, I want you to understand that there IS a good reason for using C instead of C++(-0x)/C#.

    Thanks for taking the time.

  13. Microsoft, please solve world hunger.

  14. Along with stdint.h, support for stdbool.h would make it much easier to use standard types without having to have special-case fallbacks for MSVC.

  15. I love C99's struct literals:

    return (point){ .x = 1, .y = 2, .z = 3 };

  16. Mr. Horne is correct when he says C is used far more than C++.

  17. One of the reasons I personally don't "just use subset of C++"(Infact, I do, in a few projects) is that when working in projects which have multiple people collaborating, and new people coming in and out here and there, people generally tend not to adhere to the subset; someone writes their implementation with operator overloading(or multiple inheritance or exceptions, whatever you like to diss) and if that code is not audited(and corrected to adhere to the convention) right away, it becomes problematic to maintain. After a while the blob of non-convention-adhering-code just grows too big and you feel like an idiot. Yes, this is partly a project management issue too, and infact has less to do with the languages, but I believe this is *one* of the reasons why people prefer to *enforce* to keep the "C++ bloat/issues/bad code/whatever" away from their project. It's just easier and simpler to stick with C(89/99/11). It's simple, everyone knows it(well enough, compared to "modern C++"(which has it's own, vocal fanbase)) and the potential drawbacks of lesser type safety, some neat constructs(especially with C++11, e.g. auto and lambdas) and potential performance hit(sometimes faster, sometimes slower, depends on the code and compiler. Doesn't matter in "real life").

    Laziness + "we've always done C". :)

  18. Julian Brown, you are talking out the crack in your butt. "On Windows the only thing you can make now are .NET applications. " First, this statement is odd in that you say "on windows". Don't you run gcc on windows? Perhaps you means MSVC, but not being familiar with the product you don't even know its name.

    Secondly, MSVC 2005, 2008, and 2010 all generate native code just fine. I haven't tried the latest MSVC yet as it isn't final, but I have heard nothing to indicate the situation has changed.

    Feel free to use whatever tool you prefer, but there is no need to spread misinformation.

  19. The major benefit of using C over C++ relates to internal mangling. C compilers are consistent on internal mangling, so it is actually possible to build partially with one and finish with another. C++ internal mangling isn't so well-defined. If a library is built on one C++ compiler, then it can only be used with projects compiled with that compiler. That's problematic, to say the least.

  20. How's the Intel C compiler? Quick Googling shows some level of C99 support. If you're paying for a compiler, you might as well pay for one that does what you want.

    Vivek: Nobody can agree on a safe subset of C++, so that approach creates a lot of bikeshedding.

    1. A lot of projects, especially the Open Source ones mentioned above, may not be paying for the compiler. It has historically been available for free as part of the Windows SDK.

      Visual Studio, the IDE, is what has cost money. Even then, the Express editions have been free for a long time.

  21. @Finlay: accidentally introducing compiler bugs could be disastrous for the company, I agree, but I thought this would be mitigated by their (presumably ginormous) compiler test suite?

  22. Clearly they just want to support C++ and C# and leave gcc to support C. So why not use gcc and if people try to compile your code in Visual Studio tell them to complain to Microsoft? With gcc you get the standards compliance and cross platform compatibility you are after. Gcc loves you. Microsoft doesn't love you any more.

  23. Conan Kudo: Name decoration issues can be solved with extern "C" .

  24. I case no one noticed, it's already C11 since December 2011. We should really ask for C11 support.

  25. Sheeesh. Why do people let themselves be "slaves" like this? Switch compiler and even OS already!

  26. I heard Visual C++ 2012 Express edition won't handle non-web project. Users will need to buy the PRO edition.

    It can be hard or impossible for some to switch compilers (at least without finding a new job.)

    But there are at least 3 free compilers available:

    1. Open Watcom C/C++ 1.9 or daily build
    2. MingGW (if linking to LGPL libraries are acceptable)
    3. Clang 3.2 will have improved ABI compatibility with Visual C++

    A combination of the above like using Clang with the Win32 headers provided by MingGW, etc. might be useful until we can compile with Windows SDK 7.

    I think the outcome of the Google vs Oracle copyright/patent dispute means people will be less worried about porting more of the Win32 API from Windows SDK 7. But it would be nice to directly use the SDK and Visual C++ IDE is nice, especially with a plugin adding vi emulation to the editor.

  27. One of my friend recommended me about your blog to download Ea game. Thanks a lot for this awesome share. After downloading it completely I will do pass it to my friends also.

    EA Games Help