| __BUILTIN_TYPES_COMPATIBLE_P(3) | Library Functions Manual | __BUILTIN_TYPES_COMPATIBLE_P(3) |
__builtin_types_compatible_p —
GNU extension to check equivalent types
int
__builtin_types_compatible_p(type_a,
type_b);
The
__builtin_types_compatible_p()
is a GNU extension for determining whether two types are equivalent. If
type_a is equivalent to type_b,
a value 1 is returned. Otherwise
__builtin_types_compatible_p() returns 0.
The following remarks should be taken into account.
sizeof(char
*) and sizeof(int)
result the same value on i386, but the types naturally are not
equivalent.The following example combines
__builtin_types_compatible_p() and the
typeof(3) construct:
#define __COMPARE_TYPES(v, t) \
__builtin_types_compatible_p(__typeof__(v), t)
...
if (__COMPARE_TYPES(p, double) != 0)
err(EX_DATAERR, "invalid type");
This is a non-standard, compiler-specific extension.
| December 21, 2010 | NetBSD 11.0 |