This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: warning when using __builtin_types_compatible_p
- From: John Love-Jensen <eljay at adobe dot com>
- To: Manish Verma <manish dot avtaar at googlemail dot com>, GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 28 Jul 2008 06:40:44 -0500
- Subject: Re: warning when using __builtin_types_compatible_p
Hi Manish,
> I get a warning regarding the incompatible pointer type, when I
> compile a very simple program at the bottom of this email. I must be
> doing something very silly. Does anybody an idea about it?
The foo_float routine takes a float*, but you are passing in an int*, which
is an incompatible type.
Expanding your main, this is what it looks like:
int main()
{
int a = 10;
float b = 101;
{
if(__builtin_types_compatible_p(typeof(&a), int*))
foo_int(&a);
else
foo_float(&a); // <-- warning here
}
return 0;
}
It appears that you want to use some sort of function overloading. I
suggest you use C++ as a "better C" compiler, so you can use the function
overloading feature present in C++, rather than try to mimic that C++
obfuscation feature in C.
HTH,
--Eljay