Leb*_*nen 9 c complex-numbers visual-studio visual-studio-2013
http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx
C99支持添加了visual studio 2013,但我无法在我的"C"代码中使用complex.h.
#include <stdio.h>
#include <complex.h>
int main(void)
{
double complex dc1 = 3 + 2 * I;
double complex dc2 = 4 + 5 * I;
double complex result;
result = dc1 + dc2;
printf(" ??? \n", result);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到语法错误.
编辑:抱歉缺少部分.
error C2146: syntax error : missing ';' before identifier 'dc1'
error C2065: 'dc1' : undeclared identifier
error C2088: '*' : illegal for struct
error C2086: 'double complex' : redefinition
error C2146: syntax error : missing ';' before identifier 'dc2'
error C2065: 'dc2' : undeclared identifier
error C2088: '*' : illegal for struct
error C2086: 'double complex' : redefinition
error C2146: syntax error : missing ';' before identifier 'result'
error C2065: 'result' : undeclared identifier
error C2065: 'result' : undeclared identifier
error C2065: 'dc1' : undeclared identifier
error C2065: 'dc2' : undeclared identifier
error C2065: 'result' : undeclared identifier
IntelliSense: expected a ';'
IntelliSense: expected a ';'
IntelliSense: expected a ';'
IntelliSense: identifier "result" is undefined
IntelliSense: identifier "dc1" is undefined
IntelliSense: identifier "dc2" is undefined
Run Code Online (Sandbox Code Playgroud)
Tan*_*aya 11
如果有人在一年后搜索,请尝试
_Dcomplex dc1 = {3.0, 2.0};
用于变量声明.
从查看VS2013的"complex.h"标题内部来看,似乎微软决定自己实现C复数.你必须使用real()和imag()函数实现自己的算术运算符,即:
double real_part = real(dc1) + real(dc2);
double imag_part = imag(dc1) + imag(dc2);
_Dcomplex result = {real_part, imag_part};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4394 次 |
| 最近记录: |