Add fallback atexit implementation using template descrutors

Fixes https://github.com/harfbuzz/harfbuzz/issues/3197
This commit is contained in:
Behdad Esfahbod 2021-09-14 08:12:48 -04:00
parent 9c27045158
commit bda3238c89
1 changed files with 2 additions and 1 deletions

View File

@ -449,7 +449,8 @@ static int HB_UNUSED _hb_errno = 0;
# ifdef HAVE_ATEXIT
# define hb_atexit atexit
# else
# error "atexit not found."
template <void (*function) (void)> struct hb_atexit_t { ~hb_atexit_t () { function (); } };
# define hb_atexit(f) static hb_atexit_t<f> _hb_atexit_##__LINE__;
# endif
#endif