Hi,
We would like to propose to implement a type checking macro like
__is_type_defined(type)
to check whether a type has been defined or not so far during preprocessor.
The possible usage of this macro can be illustrated by below.
…
#if !__is_type_defined(struct abc)
struct abc {
…
};
#endif
If ‘struct abc’ is defined before the ‘#if’ the __is_type_defined(struct abc) should be evaluated as true or 1. Otherwise, __is_type_defined(struct abc) should be evaluated as false or 0.
Previously we proposed attribute((bpf_dominating_decl)) and later__attribute__((bpf_accept_identical_del)). The previous discussion is at
The attribute((bpf_dominating_decl)) is not favored by upstream, and attribute((bpf_accept_identical_del)). has its own limitation for our use case.
So we propose a macro __is_type_defined(type) so clang doesn’t need to make non-default decision how to handle duplicated types. User code can handle them in their particular way with the new macro.
Is this something clang could implement?