diff --git a/src/common/bitstring.h b/src/common/bitstring.h
index 1c0d306dfc4d9a1a66496b3819475d95478ef03d..d12f51c7f272578fe51ff2db49bdaed6bd28ee57 100644
--- a/src/common/bitstring.h
+++ b/src/common/bitstring.h
@@ -15,11 +15,22 @@
  * bitstrings are zero origin
  */
 
-#include <stdint.h>
-
 #ifndef _BITSTRING_H_
 #define	_BITSTRING_H_
 
+#if HAVE_CONFIG_H
+#  include <config.h>
+#  if HAVE_INTTYPES_H
+#    include <inttypes.h>
+#  else
+#    if HAVE_STDINT_H
+#      include <stdint.h>
+#    endif
+#  endif  /* HAVE_INTTYPES_H */
+#else	/* !HAVE_CONFIG_H */
+#  include <inttypes.h>
+#endif  /*  HAVE_CONFIG_H */
+
 #define BITSTR_SHIFT_WORD8	3
 #define BITSTR_SHIFT_WORD32	5
 #define BITSTR_SHIFT_WORD64	6