diff --git a/src/connectivity/utf8_utils.cpp b/src/connectivity/utf8_utils.cpp
index 88f84da7281b17da9dd60d30aaea594930c5b3f8..32863786b8099c320659dbeb919cd08cd015c961 100644
--- a/src/connectivity/utf8_utils.cpp
+++ b/src/connectivity/utf8_utils.cpp
@@ -33,7 +33,7 @@ using ssize_t = SSIZE_T;
  * the compiler about the expected result of an expression. Some compilers
  * can use this information for optimizations.
  */
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+#if defined(__GNUC__) && (__GNUC__ > 2) || defined(__clang__)
 #define LIKELY(expr)   (__builtin_expect(expr, 1))
 #define UNLIKELY(expr) (__builtin_expect(expr, 0))
 #else