Add macro to cast function pointer to void pointer

Does not evaluate constant expression, I don't know if
that's possible.
This commit is contained in:
James R 2022-02-20 03:18:47 -08:00
parent bef9f502ca
commit 9722027fc1

View file

@ -409,4 +409,12 @@ typedef UINT64 precise_t;
#define intsign(n) \
((n) < 0 ? -1 : (n) > 0 ? 1 : 0)
// ISO C forbids function pointer -> void pointer cast but
// if it's wrapped in a struct, we can take a pointer to
// that struct and it's fine...
// Cast function pointer to (void*)
#define FUNCPTRCAST(p) ((union{void(*f)(void);void*v;})\
{(void(*)(void))p}).v
#endif //__DOOMTYPE__