complex.h: fine on linux but crashes on windows


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

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


Is some additional step required on windows?

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.


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.