MS VS 2008和C99 [英] MS VS 2008 and C99
问题描述
我感兴趣地阅读了文章 C99的支持范围如何?。其中的一项评论指出,Microsoft不支持C99。但是注释符号//与VS 2008一起使用,并且该符号在C99中。我有两个问题:
I read with interest the post "How universally is C99 supported ?". One of the comments therein points that Microsoft doesn't support C99. But the comment symbol // works with VS 2008 and this symbol is in C99. I have two questions:
-
VS 2008在多大程度上支持C99?
To what extent VS 2008 support C99?
可以在同一代码中将C89和C99语法混合在一起吗?因此,如果我用C89编写代码,然后添加注释//。这意味着我有混合编码。那么在这种情况下编译器会做什么?首先使用c89,然后使用C99检查我的代码以接受我使用//进行注释?
Is it ok in the same code to mix C89 and C99 syntax together? So if I write my code in C89 and then place a comment //. This means that I have mixed-coding. So what does the compiler do in such a case? Check my code first with c89 and then with C99 to accept that I use // for commenting?
推荐答案
MSVC在C模式下几乎不支持C99。它所做的几件事(例如 //注释)实际上是它们从C ++添加到C90模式的扩展,也可能在C99中。在编译C代码时,MSVC会将'//'注释视为C90的扩展,而不是将C90代码与C99代码混合在一起。
MSVC supports very little of C99 in C mode. The few things that it does (like '//' comments) are really extensions they've added to C90 mode that come from C++, which may happen to also be in C99. When compiling C code, MSVC treats '//' comments as an extension to C90, not that you're intermixing C90 code with C99 code.
您将获得'更好的C99支持,方法是将C文件编译为C ++-这样,您将获得声明,这些声明可以散布在 for
语句中的语句和变量声明中例如,用于
循环。
You'll get 'better' C99 support by compiling your C files as C++ - in that way you'll get declarations that can be interspersed with statements and variable declarations in for
statements that are scoped to the for
loop, for example.
Microsoft似乎对将C99支持添加到MSVC几乎没有兴趣-即使他们将某些内容从C99添加到C ++编译器模式(例如在VS2010中添加了 stdint.h
),因为在C ++ 0x中将一些其他C99内容添加到了C ++中。
Microsoft seems to have zero interest in adding C99 support to MSVC - even as they add things from C99 to the C++ compiler mode (like stdint.h
being added in VS2010) since some additional C99 things are being added to C++ in C++0x.
这篇关于MS VS 2008和C99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!