Added2: After change to static , it can correctly work in gcc 4.8.4 (ubuntu 4.8.4-2ubuntu1~14 .04.3) within bash on ubuntu on windows. But it can't work in windows10 using gcc 4.9.2(tdm-1). And i change the compiler to cygwin which has gcc 4.9.2,not the tdm-1 version. Weird, it works! So i think the complier also has some bug!
Added1: I'm very sorry i find my compiler is gcc not g++, i'm new to the program world,please forgive me. I used .c to build, but it has some memory-leak bug that i can't handle. So i change to .cpp to build, and these error come out. So this is my situation.
windows 10 elipse gcc 4.8.4. I use C language.
elipse give me an error: invalid cast from type 'void*' to type 'int*' [-fpermissive].
elipse suggest these lines have the error
FullList = malloc(N * sizeof(int));
l = malloc(N * sizeof(int));
I don't know how to correct it. Any lead would be appreciate!
this is the function which involve this sentence.
#define ALLCHK(x) if (x == NULL) {printf ("allocation error\n"); assert(x);}
void Generate_Permutation(int N, int *p)
/* generate permutation of length N in p */
/* p is zero based, but the permutation is not */
{
int i,j; /* to loop */
int lspot; /* offset in l */
int *FullList; /* unpermuted */
int *l; /* left to be used */
FullList = malloc(N * sizeof(int));
ALLCHK(FullList)
for (i=0; i<N; i++) *(FullList+i) = i+1;
l = malloc(N * sizeof(int));
ALLCHK(l)
memcpy(l, FullList, sizeof(int)*N);
for (i=0; i < N; i++) {
lspot = (int)(URan(&seed) * (N - i));
*(p+i) = *(l+lspot);
for (j=lspot; j<N-i; j++) *(l+j) = *(l+j+1);
}
free(l); free(FullList);
}
ALLCHK? - dbush