这是众所周知,微软的Visual Studio编译器不支持C99,它看起来像他们有没有计划,以支持它.
但是,编译器确实包含一些樱桃挑选的功能,如可变参数宏和long long- 请参阅此答案中的引号:
在我们收到许多关于某些C99功能的请求的地方,我们已经尝试实现它们(或类似物).一对夫妇的例子是复杂的宏,
long long,__pragma,__FUNCTION__,和__restrict.如果您在工作中发现其他C99功能,请告诉我们!我们没有从C用户那里听到太多,所以大声说出来并让自己听到- Arjun Bijanki,微软在ISO C标准委员会的代表 http://blogs.msdn.com/b/vcblog/archive/2007/11/05/iso-c-standard-update.aspx
此外,较新版本的Visual Studio似乎附带了C99所需的一些标头.
关于特定功能有很多问题 - 但我不知道的是:在哪里可以找到当前MSVC编译器支持/提供的C99功能列表?
复合文字是C99结构.即使我可以用C++做到这一点:
#include <iostream>
using namespace std;
int main() {
for (auto i : (float[2]) {2.7, 3.1}) cout << i << endl;
}
Run Code Online (Sandbox Code Playgroud)
似乎MSVC支持它作为扩展.然而,我可以得到所有编译器,编译上面提到的代码.
这是C++ 14中的一个功能吗?是否有一个不同的标准术语(在我看来,只是创建一个临时使用支撑初始化)?
旁注:"复合文字"(或者我应该称之为的任何内容)是包扩展上下文(仅提及功能)
我正在使用 Visual C++ express 2008 尝试编译类似于以下的代码:
没问题
{
...
AVRational test = {1, 1000};
...
}
Run Code Online (Sandbox Code Playgroud)
但出现问题如下:
{
...
AVRational test = (AVRational){1, 1000};
...
}
Run Code Online (Sandbox Code Playgroud)
给出了错误:
1>..\..\..\projects\test\xyz.cpp(1139) : error C2059: syntax error : '{'
1>..\..\..\projects\test\xyz.cpp(1139) : error C2143: syntax error : missing ';' before '{'
1>..\..\..\projects\test\xyz.cpp(1139) : error C2143: syntax error : missing ';' before '}'
Run Code Online (Sandbox Code Playgroud)
其中 AVRational(ffmpeg.org 库)定义为:
typedef struct AVRational{
int num; ///< numerator
int den; ///< denominator
} AVRational;
Run Code Online (Sandbox Code Playgroud)
FFmpeg 带有一些预定义的值,例如
#define AV_TIME_BASE_Q (AVRational){1, …Run Code Online (Sandbox Code Playgroud)