Why do I get "Invalid conversion from "void *" to "int**" error?

c

Solution

You already did cast the result of `malloc` to the right type. Do the same for the `realloc` calls, too.

BTW: Don’t complain that they force you to switch on the warnings. I think it’s the most sensible thing to do by default, I always use at least `-Wall -Werror`.

Problem

my code shows this warnings when compiling with "g++ -Wall -pedantic -Wno-long-long -c main.c". I have to compile in this mode, becouse its a homework and we have an application that corrects them and it uses this compile mode. - Error: invalid conversion from "void" to "int** " [-fpermissive] - Error: invalid conversion from "void" to "int* " [-fpermissive] - Error: invalid conversion from "void" to "main(int, char*)::VYSLEDEK" [-fpermissive] the same errors continue as i realloc quite a lot in my program. I tried to change almost everything in that realloc, it is still the same. Parts of the code : ``` struct VYSLEDEK { int sirka; int vyska; int zacatek_x; int zacatek_y; int soucet; } *vysledek; int **matice,**soucty; ..... matice=(int**)malloc(1*sizeof(int*)); matice[0]=(int*)malloc(1*sizeof(int)); soucty=(int**)malloc(1*sizeof(int*)); soucty[0]=(int*)malloc(1*sizeof(int)); ..... 1. matice=realloc(matice,naalokovano*2*sizeof(int*)); 2. soucty=realloc(soucty,naalokovano*2*sizeof(int*)); ..... for (i=0;i<(naalokovano*2);i++) { 3. matice[i]=realloc(matice[i],sizeof(int)); 4. soucty[i]=realloc(soucty[i],sizeof(int*)); }; ..... 5. vysledek=realloc(vysledek,vysledku*sizeof(struct VYSLEDEK*)); ``` Thank you for your help.

Original source