]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: detect and include `inttypes.h` again
authorViktor Szakats <commit@vsz.me>
Tue, 6 Jan 2026 22:50:48 +0000 (23:50 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 7 Jan 2026 15:10:23 +0000 (16:10 +0100)
For `PRI*` printf masks for fixed-size C99 types.

Also:
- add simple fallback for `PRIu32`, `PRIx32`, if `inttypes.h` is
  missing.

Cherry-picked from #20200
Ref: #20207
Follow-up to 4701a6d2ae9f0b66a0feac4061868e944353449b #19695
Ref: 60359ad5049c42f333ac179a58cda87d6e4143a0 #12275
Closes #20208

.github/scripts/cmp-config.pl
CMake/unix-cache.cmake
CMake/win32-cache.cmake
CMakeLists.txt
lib/config-os400.h
lib/config-plan9.h
lib/config-riscos.h
lib/config-win32.h
lib/curl_config-cmake.h.in
lib/curl_setup.h

index e831a97211a548f582050beec313a003419f6fbd..f12022dd5a9de85e36c19d4f30b689a35c0474cf 100755 (executable)
@@ -48,7 +48,6 @@ my %remove = (
     '#define HAVE_GSSAPI_GSSAPI_GENERIC_H 1' => 1,
     '#define HAVE_GSSAPI_GSSAPI_H 1' => 1,
     '#define HAVE_GSSAPI_GSSAPI_KRB5_H 1' => 1,
-    '#define HAVE_INTTYPES_H 1' => 1,
     '#define HAVE_LDAP_H 1' => 1,
     '#define HAVE_LDAP_SSL 1' => 1,
     '#define HAVE_LIBBROTLIDEC 1' => 1,
index f3db9f0e974ce04f80249329424f6c10c77834a0..821349cda305dc0925398a58e5c6f026ee6470ee 100644 (file)
@@ -151,6 +151,7 @@ set(HAVE_IFADDRS_H 1)
 set(HAVE_IF_NAMETOINDEX 1)
 set(HAVE_INET_NTOP 1)
 set(HAVE_INET_PTON 1)
+set(HAVE_INTTYPES_H 1)
 set(HAVE_IOCTLSOCKET 0)
 set(HAVE_IOCTLSOCKET_CAMEL 0)
 set(HAVE_IOCTLSOCKET_CAMEL_FIONBIO 0)
index e704d2195b6f6fd4d4877a1c5655c5bc4264d9cb..27cb57057a41a37e31c970ab5e9269729a2e896f 100644 (file)
@@ -31,6 +31,7 @@ if(MINGW)
   set(HAVE_DIRENT_H 1)
   set(HAVE_FTRUNCATE 1)
   set(HAVE_GETTIMEOFDAY 1)
+  set(HAVE_INTTYPES_H 1)
   set(HAVE_LIBGEN_H 1)
   set(HAVE_OPENDIR 1)
   set(HAVE_SNPRINTF 1)
@@ -55,8 +56,10 @@ else()
     set(HAVE_STDDEF_H 1)  # detected by CMake internally in check_type_size()
     set(HAVE_STDINT_H 1)  # detected by CMake internally in check_type_size()
     if(MSVC_VERSION GREATER_EQUAL 1800)
+      set(HAVE_INTTYPES_H 1)
       set(HAVE_STDBOOL_H 1)
     else()
+      set(HAVE_INTTYPES_H 0)
       set(HAVE_STDBOOL_H 0)
     endif()
     set(HAVE_BOOL_T "${HAVE_STDBOOL_H}")
index 8e5383ac98b8b0dcff41e3e23ebb7b8a64e0fe02..975f7670c7f221553fb67b16007ae00c61eeb076 100644 (file)
@@ -1461,6 +1461,7 @@ check_include_file_concat_curl("arpa/inet.h"      HAVE_ARPA_INET_H)
 check_include_file("dirent.h"         HAVE_DIRENT_H)
 check_include_file("fcntl.h"          HAVE_FCNTL_H)
 check_include_file_concat_curl("ifaddrs.h"        HAVE_IFADDRS_H)
+check_include_file("inttypes.h"       HAVE_INTTYPES_H)
 check_include_file("io.h"             HAVE_IO_H)
 check_include_file_concat_curl("libgen.h"         HAVE_LIBGEN_H)
 check_include_file("linux/tcp.h"      HAVE_LINUX_TCP_H)
index ec6c002efd785a7940515a65cbbe6c4c10fbee64..9307b44f5189cf97d664efa9732842144af9ba81 100644 (file)
@@ -96,6 +96,9 @@
 /* Define if you have the `timeval' struct. */
 #define HAVE_STRUCT_TIMEVAL
 
+/* Define if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H
+
 /* Define if you have the <io.h> header file. */
 #undef HAVE_IO_H
 
index 5303ab33997b0a28615802e3b2bfc064942dae71..5bae684b1eae80d4e8de780def404e3f4bd7b1af 100644 (file)
@@ -83,6 +83,7 @@
 #define HAVE_GMTIME_R 1
 #define HAVE_INET_NTOP 1
 #define HAVE_INET_PTON 1
+#define HAVE_INTTYPES_H 1
 #define HAVE_LIBGEN_H 1
 #define HAVE_LIBZ 1
 #define HAVE_LOCALE_H 1
index 3158c984ee3615e31d7a302a3648da8d2865323e..b58b16dc609109111bd37948245050fc2ed36a00 100644 (file)
@@ -96,6 +96,9 @@
 /* Define if you have the `timeval' struct. */
 #define HAVE_STRUCT_TIMEVAL
 
+/* Define if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H
+
 /* Define if you have the <io.h> header file. */
 #undef HAVE_IO_H
 
index 002782c6ea9e189edeecc0b3e320220a46567427..6374bd0e98a95a5672d95fa9c307974255510c7d 100644 (file)
 /* Define if you have the <fcntl.h> header file. */
 #define HAVE_FCNTL_H 1
 
+/* Define to 1 if you have the <inttypes.h> header file. */
+#if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || defined(__MINGW32__)
+#define HAVE_INTTYPES_H 1
+#endif
+
 /* Define if you have the <io.h> header file. */
 #define HAVE_IO_H 1
 
index d8d9d7ecbe58d53952b908bd0f8640d742a83d94..bde26eb984f8f0acad00fcc3f0603664631b193f 100644 (file)
 /* Define to 1 if symbol `sa_family_t' exists */
 #cmakedefine HAVE_SA_FAMILY_T 1
 
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H 1
+
 /* Define to 1 if you have the ioctlsocket function. */
 #cmakedefine HAVE_IOCTLSOCKET 1
 
index 05b4aff64e7ecdf6c32c8a2d65bc0fe16e9be4de..6d2ef483739a0d11e23c70121f85a654f6c53c74 100644 (file)
 
 #include <limits.h>
 
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#define PRIu32 "u"
+#define PRIx32 "x"
+#endif
+
 #ifdef _WIN32
 #  ifdef HAVE_IO_H
 #  include <io.h>