__BUILTIN_TYPES_COMPATIBLE_P(3)
π __builtin_types_compatible_p(3) β GNU extension to check equivalent types π
okay bestie, welcome to the Library Functions Manual β todayβs main character is __builtin_types_compatible_p(3), and itβs literally here to check if two types are equivalent. no cap. π
β¨ NAME β¨
__builtin_types_compatible_p β the GNU extension that checks whether two types are equivalent. π«Ά
πΈ SYNOPSIS πΈ
call it like this, bestie:
int
__builtin_types_compatible_p(type_a, type_b);
π¦ DESCRIPTION π¦
__builtin_types_compatible_p() is a GNU extension for determining whether two types are equivalent. If type_a is equivalent to type_b, you get the value 1. Otherwise, __builtin_types_compatible_p() returns 0. thatβs the whole vibe. β¨
The following remarks should be taken into account β think of them as the receipts you gotta keep in mind:
- The architecture-specific size of the two types does not have an impact on the result. For example,
sizeof(char *)andsizeof(int)result the same value on i386, but the types naturally are not equivalent. π - Type qualifiers are ignored. The function returns the same value for
longandconst long. π - The amount of pointer indirection affects the result. For example,
double *is not equivalent todouble **. π₯ - Two types defined with
typedefare equivalent if and only if their underlying types are equivalent. π - The
enumtype is a special case in that twoenumtypes are not considered equivalent. π
π EXAMPLES π
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");
π SEE ALSO π
go give these a lil scroll too, bestie:
β CAVEATS β
Caveat, fr fr: This is a non-standard, compiler-specific extension. π
Debian β’ December 21, 2010 β’ signing off on __builtin_types_compatible_p(3) β mwah, bestie ππ«Ά
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms