
Microsoft, please support (at least a tiny bit of) C99 - bluemoon
http://blog.reverberate.org/2012/03/02/microsoft-please-support-at-least-a-tiny-bit-of-c99/
======
haberman
Article author here. If you have similar pain, you can show your support for
this here: [http://visualstudio.uservoice.com/forums/121579-visual-
studi...](http://visualstudio.uservoice.com/forums/121579-visual-
studio/suggestions/2089423-c99-support)

I know this is probably a losing battle, but I feel better at least being able
to express my displeasure about the issue.

~~~
eliben
Voted. Thanks for doing this!

------
buster
It's not that there are no alternatives..

<http://gcc.gnu.org/>

<http://clang.llvm.org/>

<http://software.intel.com/en-us/intel-sdp-home/>

<http://www.pathscale.com/ekopath-compiler-suite>

~~~
rwmj
The 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)

~~~
DarkShikari
x264 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.

------
TwoBit
When 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
I 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
Yes, 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.

------
saurik
The stdint.h header comes with MSVC 2010.

------
chj
Do not beg. Do not use it.

~~~
batista
Yes. 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.

------
Zarathust
Surely 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
It's probably all C++ -clean, so they can compile everything as C++.

~~~
4ad
No, 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>

Sometimes the compiler versions match those of the current Visual Studio
release, but not always.

------
AshleysBrain
Doesn't Microsoft have a disincentive to support it here? It would encourage
people to use open-source alternatives to The Microsoft Way.

~~~
CurtHagenlocher
The 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
I 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.

------
TheNewAndy
I suspect that C11 support is closer than C99 support (and it would be good
too). Things like variable length arrays are now optional.

~~~
cygx
There 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
Since it means not having to support VLAs, yes.

~~~
nknight
One 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
So by your standards, Microsoft is doing quite well. After all, they do
support parts of C99 such as stdint.h.

~~~
nknight
You 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.

------
raldi
What are "for loop initial decorations"?

~~~
mvzink

      for (int i = 0; i < n; i++) { ... }
    

instead of

    
    
      int i;
      for (i = 0; i < n; i++) { ... }

