Having a little trouble with lcc-win64

C

Chris Saunders

I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3i;
printf("%d\n", cabs (dc));
return 0;
}

I am getting several errors and it seems they all relate to iostream.h line
81 and 91 and there are several different errors. I'm pretty sure that the
problem is some error in my C code. Could anyone assist?

Regards
Chris Saunders
 
M

Morris Keesan

I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h> ....
printf("%d\n", cabs (dc));

cabs() is defined as returning a double. The %d format specifier
requires an argument of type (int). This line of code is unlikely to
do anything reasonable. Try %a, %e, %f, or %g instead of %d.
 
I

Ian Collins

I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3i;

make that double _Complex dc = 1.5+2.3*I;
printf("%d\n", cabs (dc));
return 0;
}

I am getting several errors and it seems they all relate to iostream.h
line 81 and 91 and there are several different errors. I'm pretty sure
that the problem is some error in my C code. Could anyone assist?

iostream.h is an ancient C++ header...
 
S

Sjouke Burry

Chris said:
I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3i;
printf("%d\n", cabs (dc));
return 0;
}

I am getting several errors and it seems they all relate to iostream.h line
81 and 91 and there are several different errors. I'm pretty sure that the
problem is some error in my C code. Could anyone assist?

Regards
Chris Saunders
Aint that C++ ?? That is left around the corner...
 
I

Ian Collins

Chris said:
I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3i;
printf("%d\n", cabs (dc));
return 0;
}

I am getting several errors and it seems they all relate to iostream.h
line 81 and 91 and there are several different errors. I'm pretty sure
that the problem is some error in my C code. Could anyone assist?
Aint that C++ ?? That is left around the corner...

iostream.h was once upon a time, but the code above certainly isn't!
 
K

Keith Thompson

Chris Saunders said:
I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3i;
printf("%d\n", cabs (dc));
return 0;
}

I am getting several errors and it seems they all relate to iostream.h line
81 and 91 and there are several different errors. I'm pretty sure that the
problem is some error in my C code. Could anyone assist?

You say there are "several errors". Telling us what they are would
have been helpful.

There are no references to iostream.h in your code. Are you thinking
of the C++ header <iostream>? I don't know why you'd be getting
error messages that refer to it.

I see only two errors in the code you posted. One is that 2.3i is
not a valid C constant; it may be an extension provided by your
compiler. (2.3*I is portable, at least to C99 implementations.)
The other is that "%d" requires an int argument; you're passing it
a double.
 
C

Chris Saunders

I rewrote the program as follows:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3*I;
printf("%g\n", cabs (dc));
return 0;
}

This appears to me to be corrected as suggested. I am still getting errors
about iostream.h and I will include the entire list below. I didn't include
these before because I thought this might be a problem particular to
lcc-win64. I have no idea where iostream.h is coming from.

Wedit output window build: Fri Jul 16 04:51:26 2010
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 Syntax error; missing semicolon before
`<<'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 skipping `<<'
Warning c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 no type specified. Defaulting to int
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 syntax error; found `*' expecting ')'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 redefinition of 'iostream'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 48 Previous definition of 'iostream' here
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 Syntax error; missing semicolon before `*'
Warning c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 no type specified. Defaulting to int
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 missing identifier
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 Syntax error; missing semicolon before
`char'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 Syntax error; missing semicolon before `)'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 skipping `)'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 redefinition of 'operator'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 Previous definition of 'operator' here
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 Syntax error; missing semicolon before
`<<'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 skipping `<<'
Warning c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 no type specified. Defaulting to int
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 syntax error; found `*' expecting ')'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 redefinition of 'iostream'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 81 Previous definition of 'iostream' here
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 Syntax error; missing semicolon before `*'
Warning c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 no type specified. Defaulting to int
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 missing identifier
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 Syntax error; missing semicolon before
`int'
Error c:\users\chris\documents\lcc64\testcomplex\testcomplex.c:
c:\lcc\include64\iostream.h: 91 too many errors
Compilation + link time:0.3 sec, Return code: 1

Regards
Chris Saunders
 
A

Alan Curry

I rewrote the program as follows:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3*I;
printf("%g\n", cabs (dc));
return 0;
}

This appears to me to be corrected as suggested. I am still getting errors
about iostream.h and I will include the entire list below. I didn't include
these before because I thought this might be a problem particular to
lcc-win64. I have no idea where iostream.h is coming from.

I'll bet it's coming from the <complex.h>, because your C compiler doesn't
support complex types, and doesn't provide a complex.h header, and it's
somehow finding another header named complex.h that was intended for use with
a C++ compiler.
 
C

Chris Saunders

Thanks for the reply Alan. I believe that this compiler does support the
complex type. I can't be certain but this type is mentioned in the
documentation.

Regards
Chris Saunders

Alan Curry said:
I rewrote the program as follows:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3*I;
printf("%g\n", cabs (dc));
return 0;
}

This appears to me to be corrected as suggested. I am still getting
errors
about iostream.h and I will include the entire list below. I didn't
include
these before because I thought this might be a problem particular to
lcc-win64. I have no idea where iostream.h is coming from.

I'll bet it's coming from the <complex.h>, because your C compiler doesn't
support complex types, and doesn't provide a complex.h header, and it's
somehow finding another header named complex.h that was intended for use
with
a C++ compiler.
 
J

Jens Thoms Toerring

Chris Saunders said:
Thanks for the reply Alan. I believe that this compiler does support the
complex type. I can't be certain but this type is mentioned in the
documentation.

Perhaps you should ask in the newsgroup dedicated to the lcc
compiler, comp.compilers.lcc. As far as I can see lcc-win64
isn't yet "finished", so some features may still be missing,
and people in comp.compilers.lcc probably will have the most
up to date information (especially Jacob Navia, the author of
lcc-win32 and lcc-win64).
Regards, Jens
 
B

Ben Bacarisse

Chris Saunders said:
Thanks for the reply Alan. I believe that this compiler does support
the complex type. I can't be certain but this type is mentioned in
the documentation.

Yes, it does support _Complex[1]. However, if I try your corrected
version I get no errors and the correct result from lcc-win32. (OK, it
runs in a emulated environment but I doubt that can fix the errors you
see.) I suspect something wrong in your set-up.

[1] There's a bug when you use _Complex without including complex.h but
that won't affect you.

<snip>
 
K

Keith Thompson

Sjouke Burry said:
Chris said:
I have not been coding in C for a long time and here is the code I
attampted:

#include <stdio.h>
#include <complex.h>
#include <math.h>

int main(int argc,char *argv[])
{
printf("Testing complex numbers.\n");
double _Complex dc = 1.5+2.3i;
printf("%d\n", cabs (dc));
return 0;
}

I am getting several errors and it seems they all relate to iostream.h line
81 and 91 and there are several different errors. I'm pretty sure that the
problem is some error in my C code. Could anyone assist?
Aint that C++ ?? That is left around the corner...

It's entirely plausible that one of the internal headers used to
implement <stdio.h> is called "iostream.h", which may or may not be
related to the old C++ header by that name.
 
A

Alan Curry

Thanks for the reply Alan. I believe that this compiler does support the
complex type. I can't be certain but this type is mentioned in the
documentation.

I still think that the likely answer is that the compiler is finding the
wrong complex.h because the right one is missing, or the C++ compiler dropped
its include files into the C compiler's search path.

Too bad you didn't get an error message that includes the full path and
#include-ancestry of the file where the errors are found...
Regards
Chris Saunders

"Alan Curry" <[email protected]> wrote in message
[snip useless out-of-order fullquote - please learn to quote properly]
 
K

Keith Thompson

I still think that the likely answer is that the compiler is finding the
wrong complex.h because the right one is missing, or the C++ compiler dropped
its include files into the C compiler's search path.

Too bad you didn't get an error message that includes the full path and
#include-ancestry of the file where the errors are found...

It's quite possible that he did; he never actually showed us the
error messages. (Hint.)
 
K

Keith Thompson

Keith Thompson said:
It's quite possible that he did; he never actually showed us the
error messages. (Hint.)

Correction: He's posted the actual error messages in comp.compilers.lcc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top