From 292c100d6141eb2e981fa632602d73768f748727 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 Jul 2018 13:16:52 +0200 Subject: [PATCH] Always compile (but not use) alignof() and round() fallback codes Catches compile-errors in them better. --- src/hb-private.hh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/hb-private.hh b/src/hb-private.hh index 8609e04a8..48a7db10e 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -78,6 +78,17 @@ extern "C" void hb_free_impl(void *ptr); /* Compiler attributes */ +template +struct _hb_alignof +{ + struct s + { + char c; + T t; + }; + static constexpr unsigned int value = offsetof (s, t); +}; + #if __cplusplus < 201103L #ifndef nullptr @@ -104,16 +115,6 @@ extern "C" void hb_free_impl(void *ptr); #ifndef alignof #define alignof(x) (_hb_alignof::value) -template -struct _hb_alignof -{ - struct s - { - char c; - T t; - }; - static constexpr unsigned int value = offsetof (s, t); -}; #endif // alignof #endif // __cplusplus < 201103L @@ -1258,7 +1259,6 @@ struct hb_bytes_t /* fallback for round() */ -#if !defined (HAVE_ROUND) && !defined (HAVE_DECL_ROUND) static inline double _hb_round (double x) { @@ -1267,6 +1267,7 @@ _hb_round (double x) else return ceil (x - 0.5); } +#if !defined (HAVE_ROUND) && !defined (HAVE_DECL_ROUND) #define round(x) _hb_round(x) #endif