diff --git a/libavcodec/common.h b/libavcodec/common.h
index ff7e0169847084ae3f91775fbc34100746998cd6..22947916d97dcff4fd85b8d6239e2f549c93e6bf 100644
--- a/libavcodec/common.h
+++ b/libavcodec/common.h
@@ -30,6 +30,7 @@
 #    include <stdio.h>
 #    include <string.h>
 #    include <ctype.h>
+#    include <limits.h>
 #    ifndef __BEOS__
 #        include <errno.h>
 #    else
@@ -130,7 +131,7 @@ typedef unsigned int  uint_fast32_t;
 #endif
 
 #ifndef INT_BIT
-#    if INT_MAX == INT64_MAX
+#    if INT_MAX != 2147483647
 #        define INT_BIT 64
 #    else
 #        define INT_BIT 32