Skip to content

Commit

Permalink
build: delete HAVE_STDINT_H and HAVE_INTTYPES_H
Browse files Browse the repository at this point in the history
We use `stdint.h` unconditionally in all places except one. These uses
are imposed by external dependencies / features. nghttp2, quic, wolfSSL
and `HAVE_MACH_ABSOLUTE_TIME` do require this C99 header. It means that
any of these features make curl require a C99 compiler. (In case of
MSVC, this means Visual Studio 2010 or newer.)

This patch changes the single use of `stdint.h` guarded by
`HAVE_STDINT_H` to use `stdint.h` unconditionally. Also stop using
`inttypes.h` as an alternative there. `HAVE_INTTYPES_H` wasn't used
anywhere else, allowing to delete this feature check as well.

Closes curl#12275
  • Loading branch information
vszakats committed Nov 6, 2023
1 parent ba281e5 commit 60359ad
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 77 deletions.
9 changes: 0 additions & 9 deletions CMake/Platforms/WindowsCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ if(MINGW)
set(HAVE_UNISTD_H 1)
set(HAVE_LIBGEN_H 1)
set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size()
set(HAVE_STDINT_H 1)
set(HAVE_STDBOOL_H 1)
set(HAVE_BOOL_T "${HAVE_STDBOOL_H}")
set(HAVE_INTTYPES_H 1)
set(HAVE_STRTOLL 1)
set(HAVE_BASENAME 1)
set(HAVE_STRCASECMP 1)
Expand All @@ -55,18 +53,11 @@ else()
set(HAVE_LOCALE_H 1)
set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size()
set(HAVE_STDATOMIC_H 0)
if(NOT MSVC_VERSION LESS 1600)
set(HAVE_STDINT_H 1)
else()
set(HAVE_STDINT_H 0)
endif()
if(NOT MSVC_VERSION LESS 1800)
set(HAVE_STDBOOL_H 1)
set(HAVE_INTTYPES_H 1)
set(HAVE_STRTOLL 1)
else()
set(HAVE_STDBOOL_H 0)
set(HAVE_INTTYPES_H 0)
set(HAVE_STRTOLL 0)
endif()
set(HAVE_BOOL_T "${HAVE_STDBOOL_H}")
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,6 @@ if(WIN32)
endif()
endif()

check_include_file_concat("inttypes.h" HAVE_INTTYPES_H)
check_include_file_concat("sys/filio.h" HAVE_SYS_FILIO_H)
check_include_file_concat("sys/wait.h" HAVE_SYS_WAIT_H)
check_include_file_concat("sys/ioctl.h" HAVE_SYS_IOCTL_H)
Expand Down Expand Up @@ -1141,7 +1140,6 @@ check_include_file_concat("poll.h" HAVE_POLL_H)
check_include_file_concat("pwd.h" HAVE_PWD_H)
check_include_file_concat("stdatomic.h" HAVE_STDATOMIC_H)
check_include_file_concat("stdbool.h" HAVE_STDBOOL_H)
check_include_file_concat("stdint.h" HAVE_STDINT_H)
check_include_file_concat("strings.h" HAVE_STRINGS_H)
check_include_file_concat("stropts.h" HAVE_STROPTS_H)
check_include_file_concat("termio.h" HAVE_TERMIO_H)
Expand Down
1 change: 0 additions & 1 deletion lib/config-amigaos.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#define HAVE_ARPA_INET_H 1
#define HAVE_CLOSESOCKET_CAMEL 1
#define HAVE_INTTYPES_H 1
#define HAVE_IOCTLSOCKET_CAMEL 1
#define HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1
#define HAVE_LONGLONG 1
Expand Down
6 changes: 0 additions & 6 deletions lib/config-os400.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@
/* 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

Expand Down Expand Up @@ -152,9 +149,6 @@
/* Define if you have the `socket' function. */
#define HAVE_SOCKET

/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H


/* The following define is needed on OS400 to enable strcmpi(), stricmp() and
strdup(). */
Expand Down
2 changes: 0 additions & 2 deletions lib/config-plan9.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
#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
Expand All @@ -117,7 +116,6 @@
#define HAVE_SOCKET 1
#define HAVE_SSL_GET_SHUTDOWN 1
#define HAVE_STDBOOL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STRCASECMP 1
#define HAVE_STRDUP 1
#define HAVE_STRTOK_R 1
Expand Down
6 changes: 0 additions & 6 deletions lib/config-riscos.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@
/* 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

Expand Down Expand Up @@ -144,9 +141,6 @@
/* Define if you have the `socket' function. */
#define HAVE_SOCKET

/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP

Expand Down
11 changes: 0 additions & 11 deletions lib/config-win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@
/* 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 to 1 if you have the <stdint.h> header file. */
#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(__MINGW32__) || \
(defined(__BORLANDC__) && (__BORLANDC__ >= 0x0582)) || defined(__POCC__)
#define HAVE_STDINT_H 1
#endif

/* Define if you have the <io.h> header file. */
#define HAVE_IO_H 1

Expand Down
6 changes: 0 additions & 6 deletions lib/curl_config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@
/* Define to 1 if symbol `ADDRESS_FAMILY' exists */
#cmakedefine HAVE_ADDRESS_FAMILY 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

Expand Down Expand Up @@ -503,9 +500,6 @@
/* Define to 1 if you have the <stdbool.h> header file. */
#cmakedefine HAVE_STDBOOL_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1

/* Define to 1 if you have the strcasecmp function. */
#cmakedefine HAVE_STRCASECMP 1

Expand Down
6 changes: 1 addition & 5 deletions lib/curl_setup_once.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
#endif

#ifdef USE_WOLFSSL
# if defined(HAVE_STDINT_H)
# include <stdint.h>
# elif defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
#include <stdint.h>
#endif

#ifdef USE_SCHANNEL
Expand Down
29 changes: 0 additions & 29 deletions m4/curl-functions.m4
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,6 @@ curl_includes_ifaddrs="\
])


dnl CURL_INCLUDES_INTTYPES
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when inttypes.h is to be included.

AC_DEFUN([CURL_INCLUDES_INTTYPES], [
curl_includes_inttypes="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
/* includes end */"
case $host_os in
irix*)
ac_cv_header_stdint_h="no"
;;
esac
AC_CHECK_HEADERS(
sys/types.h stdint.h inttypes.h,
[], [], [$curl_includes_inttypes])
])


dnl CURL_INCLUDES_LIBGEN
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
Expand Down
2 changes: 2 additions & 0 deletions scripts/cmp-config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'#define HAVE_DECL_GETPWUID_R 1' => 1,
'#define HAVE_DLFCN_H 1' => 1,
'#define HAVE_GETHOSTBYNAME 1' => 1,
'#define HAVE_INTTYPES_H 1' => 1,
'#define HAVE_IOCTL 1' => 1,
'#define HAVE_LDAP_SSL 1' => 1,
'#define HAVE_LIBBROTLIDEC 1' => 1,
Expand All @@ -57,6 +58,7 @@
'#define HAVE_OPENSSL_X509_H 1' => 1,
'#define HAVE_SA_FAMILY_T 1' => 1,
'#define HAVE_SETJMP_H 1' => 1,
'#define HAVE_STDINT_H 1' => 1,
'#define HAVE_STDIO_H 1' => 1,
'#define HAVE_STDLIB_H 1' => 1,
'#define HAVE_STRING_H 1' => 1,
Expand Down

0 comments on commit 60359ad

Please sign in to comment.