This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]