diff --git a/src/msvc/msvc_compat.h b/src/msvc/msvc_compat.h
index aef86b05..57f3f42d 100644
--- a/src/msvc/msvc_compat.h
+++ b/src/msvc/msvc_compat.h
@@ -32,10 +32,21 @@
 
 #define PATH_MAX _MAX_PATH
 
-#define __builtin_popcount __popcnt 
-
 #define setvbuf msvc_setvbuf
 
+static inline int __builtin_popcount(unsigned int v)
+{
+    int count = 0;
+
+    while (v)
+    {
+        count += v & 1;
+        v >>= 1;
+    }
+
+    return count;
+}
+
 static inline int msvc_setvbuf(
     FILE* const public_stream,
     char* const buffer,