jbravo1
December 11, 2018, 9:17pm
1
Hi,
Below is a small C program that prints e^i.
#include <stdio.h>
#include <complex.h>
int main(void)
{
printf("e^i = %lf + %lf i\n",creal(cexp(I)),cimag(cexp(I)));
}
Compiling on linux works fine
pgcc -o my_prog main.c
./my_prog
e^i = 0.540302 + 0.841471 i
However, when compiling on windows, the code crashes without throwing an error message.
pgcc -o my_prog main.c
.\my_prog
Is some additional step required on windows?
jbravo1
December 11, 2018, 9:27pm
2
Adding to my question above:
I had a look at complex.h in windows and linux directories.
The windows header file seems to be missing lines relevant to cepx
E.g. The lines
double _Complex cexp(double _Complex);
#define cexp(x) __builtin_cexp(x)
double _Complex __builtin_cexp(double _Complex);
Are missing from the windows version of complex.
jbravo1
December 11, 2018, 9:49pm
3
Update:
I managed to temporarily fix the problem by manually adding the relevant cexp lines to the complex.h header file. The code seems to be operating normally now.