如何在Windows上使用带有叮当声的C99复数?
我已经安装了VisualStudio2019,它发出了铿锵的声音。我可以使用如何在Windows上使用带有叮当声的C99复数?,c,windows,clang,c99,C,Windows,Clang,C99,我已经安装了VisualStudio2019,它发出了铿锵的声音。我可以使用clang成功编译和链接应用程序 但是,当我#include时,我不会得到符合标准的复数 下面是一个在包含后不起作用的示例 它告诉我,complex关键字未声明 error: use of undeclared identifier 'complex' 但是,我能够使用Microsoft非标准复数。这是一个完整的程序 #include <stdio.h> #include <complex.h>
clang
成功编译和链接应用程序
但是,当我#include
时,我不会得到符合标准的复数
下面是一个在包含
后不起作用的示例
它告诉我,complex
关键字未声明
error: use of undeclared identifier 'complex'
但是,我能够使用Microsoft非标准复数。这是一个完整的程序
#include <stdio.h>
#include <complex.h>
int main( int argc, char *argv[] ) {
_Fcomplex z = { 2.0f, 3.0f };
printf( "z = %f + %f * i\n", crealf( z ), cimagf( z ) );
return 0;
}
我可以在Windows上使用clang获得符合标准的复数吗?编译器及其使用的库是分开的。即使您正在使用
clang
进行编译
complex.h头的Microsoft实现将这些类型定义为C99标准本机复杂类型的等效类型:
Standard type Microsoft type
float complex or float _Complex _Fcomplex
double complex or double _Complex _Dcomplex
long double complex or long double _Complex _Lcomplex
您可以使用typedef和宏来平滑其中的一部分。Complex有效吗?即使你使用了clang,库仍然来自VS,VS并不是真正的C99兼容。是的,_Complex“起作用”,但我不能创建一个虚数,因为
I
是我从错误消息中收集的\u Fcomplex
类型。是的,正如我所想的那样。你真倒霉。您无法获得对complex.h
的实际库支持。mingw可能是Windows上C的更好选项…;)
z = 2.000000 + 3.000000 * i
Standard type Microsoft type
float complex or float _Complex _Fcomplex
double complex or double _Complex _Dcomplex
long double complex or long double _Complex _Lcomplex