I'm trying to check whether a given macro token is a pointer (__builtin_classify_type(...) == 5), but I'm running into an issue where the defined outputs of this builtin are not accurate.
After running through some tests, this is a type array I came up with (where x's are unknown/not found):
char* classes[] = {"x" , "integer/enum/char/long/size_t" , "x" ,
"x" , "x" , "pointer/void/string/array/function" ,
"x" , "x" , "float/double" ,
"complex", "x" , "x" ,
"struct" , "union" , "x" ,
"x" , "x" , "x" };
Compare this with the enum present in typeclass.h,
enum type_class
{
no_type_class = -1,
void_type_class, integer_type_class, char_type_class,
enumeral_type_class, boolean_type_class,
pointer_type_class, reference_type_class, offset_type_class,
real_type_class, complex_type_class,
function_type_class, method_type_class,
record_type_class, union_type_class,
array_type_class, string_type_class,
lang_type_class
};
Most of the classes I don't care about, or can't even find their definition to test (record, real, lang, etc.) My whole reasoning for using __builtin_classify_type was to identify pointers, but if it's going to also match voids, strings, arrays, and functions under the same class, then there's really no use for it.
Anyone know why __builtin_classify_type is returning values inconsistent with typeclass.h?