Is it a bad idea to create a generic "function pointer" union in C?
What you're doing is valid. As long as you're calling the pointed-to function via the proper pointer type, it's well defined.
This union could get big however depending on how many different function types you have to support, and you have to keep it in sync with your set of typedefs. As it turns out you can freely convert from one function pointer type to another via a cast, you just need to make sure you call it with the proper type.
Section 22.214.171.124p8 of the C standard say the following about function pointer conversions:
A pointer to a function of one type may be converted to a pointer to a function of another type and back again; the result shall compare equal to the original pointer. If a converted pointer is used to call a function whose type is not compatible with the referenced type, the behavior is undefined.
So you could also just use
void (*)() as a generic pointer type instead of using a union, then you would need to apply the proper cast when you call it. For example:
typedef void (*FP)(); FP fp = setdata; ... ((PFVAI)fp)(123);