As discussed on comp.lang.c, I am posting about complex number sup****t
in lcc-win32. I was going to post about a number of issues, but I
think, now, that are mostly related.
I suspect that the problem is either than I simply don't know what I
am doing, or lcc-win32 is missing some basic elements of C99 complex
arithmetic because the first problem is simply this:
-------- 1.c ---------
int main(void)
{
double _Complex x = 1.0;
return 0;
}
--- lcc-win32 says ---
Error 1.c: 3 operands of = have illegal types 'struct long double
_Complex' and 'double'
----------------------
This is with or without the -ansic flag. Adding #include <complex.h>
and the problem is goes away, *unless* -ansic is specified:
-------- 2.c ---------
#include <complex.h>
int main(void)
{
double _Complex x = 1.0;
return 0;
}
--- lcc -ansic says ---
Error 2.c: 5 operands of = have illegal types 'struct long double
_Complex' and 'double'
-----------------------
These are so basic that I suspect I am missing something, but I can't
see what. No programs with complex numbers seem to work when I use
the -ansic flag, but that flag is needed or I can't compile:
-------- 7.c ---------
#include <stdio.h>
#include <complex.h>
int operator = (42);
int main(void)
{
double _Complex x = 1+2*I;
printf("%d\n", operator);
return 0;
}
--- lcc-win32 says ---
Error 7.c: 4 syntax error; found `42' expecting ')'
Error 7.c: 4 skipping `42'
Error 7.c: 4 incorrect number of arguments to operator asgn
Error 7.c: 9 undeclared identifier 'operator'
Warning 7.c: complex-7.c: 9 possible usage of operator before definition
----------------------
A couple of small points (and neither depends on the -ansic flag) are:
_Complex_I seems not to be defined in complex.h and the types of creal
and cimag seem to be wrong:
-------- 5.c ---------
#include <stdio.h>
#include <complex.h>
int main(void)
{
double _Complex x = _Complex_I;
printf("%g+%gI\n", creal(x), cimag(x));
return 0;
}
--- lcc-win32 says ---
Error 5.c: 6 undeclared identifier '_Complex_I'
Warning 5.c: 7 printf argument mismatch for format g. Expected double
got long double
Warning 5.c: 7 printf argument mismatch for format g. Expected double
got long double
Warning 5.c: 6 possible usage of _Complex_I before definition
----------------------
--
Ben.


|