I am not sure that I understand your question completely. You mean that you have a type generic macro that is given by some library and you want to amend it with a new type of your own?
What you always could do is to give it another name and use the default case to obtain the provided behavior:
#define to_str2(X) _Generic((X), default: to_str(X), int: i_str(X))
Edit:
This will not work perfectly because you'd have to put the function argument evaluation inside the _Generic
. This means in particular that the type of X
has to be compatible with all branches of the nested generic expressions.
It would be easier if the library in question had a macro that would just return the function itself, without the (X)
, say to_strGen
, and that never would evaluate X
. Then you could do
#define to_str2Gen(X) _Generic((X), default: to_strGen(X), int: i_str)
#define to_str2(X) to_str2Gen(X)(X)