S
somenath
Is void * and void ** is compatible?
I do not get any compiler warning or error message for the first two functions (written below) but for the third one the compiler throws the followingwarning
gcc -ansi -pedantic -Wall test.c
test.c: In function ‘TestChar’:
test.c:17:5: warning: return from incompatible pointer type
#include<stdlib.h>
void **TestVoid()
{
void *p =malloc(2);
return p;
}
void *TestVoid2()
{
void **p =malloc(2);
return p;
}
char **TestChar()
{
char *p = malloc(2);
return p;
}
int main(void)
{
return 0;
}
It is clear that char* and char** is not compatible. But is it not true for void* and void**?
I do not get any compiler warning or error message for the first two functions (written below) but for the third one the compiler throws the followingwarning
gcc -ansi -pedantic -Wall test.c
test.c: In function ‘TestChar’:
test.c:17:5: warning: return from incompatible pointer type
#include<stdlib.h>
void **TestVoid()
{
void *p =malloc(2);
return p;
}
void *TestVoid2()
{
void **p =malloc(2);
return p;
}
char **TestChar()
{
char *p = malloc(2);
return p;
}
int main(void)
{
return 0;
}
It is clear that char* and char** is not compatible. But is it not true for void* and void**?