大佬教程收集整理的这篇文章主要介绍了为什么’int16_t complex’不起作用?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
码:
#include <complex.h> #include <stdint.h> #include <stdio.h> int main() { float complex x = I + I / 3 * I / 2; short int complex y = I + I / 3 * I / 2; int16_t complex z = I + I / 3 * I / 2; /* Why ? */ printf("x=(%+f,%+f)\n",creal(X),cimag(X)); printf("y=(%+f,creal(y),cimag(y)); printf("z=(%+f,creal(z),cimag(z)); /* Why ? */ return 0; }
错误:
In file included from ./complex.c:1:0: ./complex.c: In function ‘main’: ./complex.c:9:13: error: two or more data types in declaration specifiers int16_t complex z = I + I / 3 * I / 2; /* Why ? */
编译器命令行:
gcc-5 --std=c99 ./complex.c -o ./complex gcc-4.9 --std=c99 ./complex.c -o ./complex
_Complex是类型@L_696_6@的一部分,就像long一样.你不能这样做:
typedef double dbl; typedef long dbl ldbl;
即,当使用typedef为double时,尝试为long double定义ldbl的typedef!同样,在定义复杂类型时不能使用typedef(例如int16_t is),而是使用short int _Complex.
(当然这也适用于复杂,因为它只是一个扩展到_Complex的宏).
以上是大佬教程为你收集整理的为什么’int16_t complex’不起作用?全部内容,希望文章能够帮你解决为什么’int16_t complex’不起作用?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。