According to the docs, I read C99 and later float complex, double complexand long double complexas complex types. However, this code compiles without warning when used gcc -Wall -Wextra.
#include <stdio.h>
#include <complex.h>
int main() {
int a, b, c, d;
float re, im;
scanf("%d %d", &a, &b);
complex matrix[a][b];
for(c=0; c<a; c++) {
for(d=0; d<b; d++) {
scanf("%f%fi", &re, &im);
matrix[c][d] = re + im * I;
}
}
for(c=0; c<a; c++) {
for(d=0; d<b; d++) {
printf("%.2f%+.2fi ", creal(matrix[c][d]), cimag(matrix[c][d]));
}
printf("\n");
}
}
- Is it valid C or is it gcc odd?
- What type
complex matrix[a][b];gives us?
If you compile it with clang, you will get:
main.c: 9: 5: warning: plain '_Complex' requires a type specifier; assuming '_Complex double'
See clang output .
The gcc error is now reported in this link . (Not me.)
source
share