MS VS 2008 and C99

烈酒焚心 提交于 2019-12-11 10:37:05

问题


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:

  1. To what extent VS 2008 support C99?

  2. 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?


回答1:


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.

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 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.



来源:https://stackoverflow.com/questions/2656080/ms-vs-2008-and-c99

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!