Skip to content

CURLOPT: bump CURLPROXY_* enums to long, drop casts#18054

Closed
vszakats wants to merge 4 commits intocurl:masterfrom
vszakats:proxylong
Closed

CURLOPT: bump CURLPROXY_* enums to long, drop casts#18054
vszakats wants to merge 4 commits intocurl:masterfrom
vszakats:proxylong

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jul 28, 2025

This patch bumps the size of these macros from int to long, while
keeping their actual values the same. It may cause incompatibilities in
user code, requiring the bump of holder variables and/or adding casts:

  • CURLPROXY_HTTP
  • CURLPROXY_HTTP_1_0
  • CURLPROXY_HTTPS
  • CURLPROXY_HTTPS2
  • CURLPROXY_SOCKS4
  • CURLPROXY_SOCKS4A
  • CURLPROXY_SOCKS5
  • CURLPROXY_SOCKS5_HOSTNAME

Also:

  • keep existing cast within the documentation to make sure it applies
    to older curl versions as well.

@vszakats vszakats marked this pull request as draft July 28, 2025 09:08
@vszakats vszakats marked this pull request as ready for review July 28, 2025 10:06
@vszakats vszakats closed this in 1a12663 Jul 28, 2025
@vszakats vszakats deleted the proxylong branch July 28, 2025 15:33
@dg0yt
Copy link
Contributor

dg0yt commented Sep 5, 2025

It may cause incompatibilities in user code, requiring the bump of holder variables and/or adding casts:

Testing 8.16.0 in rc3 in vcpkg sees a single port failing: cmake, regardless of platform, debug build.
From x64-linux:

[386/554] /usr/bin/c++ -DCURL_STATICLIB -I/mnt/vcpkg-ci/b/cmake/x64-linux-dbg/Utilities -I/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest -I/mnt/vcpkg-ci/b/cmake/x64-linux-dbg/Source -I/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source -I/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/LexerParser -isystem /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Utilities/std -isystem /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Utilities -isystem /mnt/vcpkg-ci/installed/x64-linux/include -isystem /mnt/vcpkg-ci/installed/x64-linux/include/libxml2 -fPIC -g -std=c++17 -Wno-deprecated-declarations -MD -MT Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o -MF Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o.d -o Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o -c /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx
FAILED: Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o 
/usr/bin/c++ -DCURL_STATICLIB -I/mnt/vcpkg-ci/b/cmake/x64-linux-dbg/Utilities -I/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest -I/mnt/vcpkg-ci/b/cmake/x64-linux-dbg/Source -I/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source -I/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/LexerParser -isystem /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Utilities/std -isystem /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Utilities -isystem /mnt/vcpkg-ci/installed/x64-linux/include -isystem /mnt/vcpkg-ci/installed/x64-linux/include/libxml2 -fPIC -g -std=c++17 -Wno-deprecated-declarations -MD -MT Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o -MF Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o.d -o Source/CMakeFiles/CTestLib.dir/CTest/cmCTestCurl.cxx.o -c /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx
In file included from /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Utilities/cm3p/curl/curl.h:8,
                 from /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.h:12,
                 from /mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx:3:
/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx: In member function ‘void cmCTestCurl::SetProxyType()’:
/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx:267:25: error: invalid conversion from ‘long int’ to ‘curl_proxytype’ [-fpermissive]
  267 |   this->HTTPProxyType = CURLPROXY_HTTP;
      |                         ^~~~~~~~~~~~~~
      |                         |
      |                         long int
/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx:279:31: error: invalid conversion from ‘long int’ to ‘curl_proxytype’ [-fpermissive]
  279 |         this->HTTPProxyType = CURLPROXY_HTTP;
      |                               ^~~~~~~~~~~~~~
      |                               |
      |                               long int
/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx:281:31: error: invalid conversion from ‘long int’ to ‘curl_proxytype’ [-fpermissive]
  281 |         this->HTTPProxyType = CURLPROXY_SOCKS4;
      |                               ^~~~~~~~~~~~~~~~
      |                               |
      |                               long int
/mnt/vcpkg-ci/b/cmake/src/v4.0.0-ab41915bda.clean/Source/CTest/cmCTestCurl.cxx:283:31: error: invalid conversion from ‘long int’ to ‘curl_proxytype’ [-fpermissive]
  283 |         this->HTTPProxyType = CURLPROXY_SOCKS5;
      |                               ^~~~~~~~~~~~~~~~
      |                               |
      |                               long int

@dg0yt
Copy link
Contributor

dg0yt commented Sep 5, 2025

FTR the cmake port serves as a pure CI test. The version is 4.0.0.

@vszakats
Copy link
Member Author

vszakats commented Sep 5, 2025

@dg0yt Thanks for the info. CMake was using the undocumented curl_proxytype
type. This type still exists for compatibility, but it seems the C++ compiler is not
happy that the assigned value isn't an enum of that type anymore?

It was fixed a couple of days ago in CMake:
Kitware/CMake@c814307
Kitware/CMake@c92268f

This fixes the wrong type passed previously to curl_easy_setopt():
https://github.com/Kitware/CMake/blob/58bde95a0ae721a8d15ab8cf6293cbd2c5c9ab48/Source/CTest/cmCTestCurl.cxx#L110

@vszakats
Copy link
Member Author

vszakats commented Sep 8, 2025

Slightly off-topic comment here (for better of worse): The CMake source above has many other calls passing int instead of long to curl_easy_setopt(). For a long time, curl public headers have been showing compiler warnings for these in GCC 4.3+ builds. curl 8.16.0 extended this to llvm/clang 14+. Yet, when building CMake, apparently no such warning is shown. Reason is that the checker logic doesn't support C++. It uses __builtin_types_compatible_p(), which is only available for C.

Ref: https://curl.se/mail/lib-2008-02/0267.html
Ref: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005ftypes_005fcompatible_005fp

fossdd added a commit to fossdd/xbmc that referenced this pull request Sep 10, 2025
curl 8.16.0 bumped the enums to long, see: curl/curl#18054

This fixes the build with curl 8.16+ for the following failure:

	/builds/alpine/aports/community/kodi/src/xbmc-21.2-Omega/xbmc/filesystem/CurlFile.cpp:48:5: error: cannot initialize an array element of type 'curl_proxytype' with an rvalue of type 'long'
	   48 |     CURLPROXY_HTTP,   CURLPROXY_SOCKS4,          CURLPROXY_SOCKS4A,
	      |     ^~~~~~~~~~~~~~
	/usr/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
	  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
	      |                                   ^~
	...
arnout pushed a commit to buildroot/buildroot that referenced this pull request Sep 12, 2025
curl 8.16.0 bumped the enums to long, see
curl/curl#18054

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
tiben20 pushed a commit to tiben20/xbmc that referenced this pull request Sep 15, 2025
curl 8.16.0 bumped the enums to long, see: curl/curl#18054

This fixes the build with curl 8.16+ for the following failure:

	/builds/alpine/aports/community/kodi/src/xbmc-21.2-Omega/xbmc/filesystem/CurlFile.cpp:48:5: error: cannot initialize an array element of type 'curl_proxytype' with an rvalue of type 'long'
	   48 |     CURLPROXY_HTTP,   CURLPROXY_SOCKS4,          CURLPROXY_SOCKS4A,
	      |     ^~~~~~~~~~~~~~
	/usr/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
	  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
	      |                                   ^~
	...
@michael-o
Copy link
Contributor

Just bitten by this: #18611

arnout pushed a commit to buildroot/buildroot that referenced this pull request Sep 19, 2025
curl 8.16.0 bumped the enums to long, see
curl/curl#18054

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit 3ed6c8e)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Sep 19, 2025
curl 8.16.0 bumped the enums to long, see
curl/curl#18054

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit 3ed6c8e)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Sep 19, 2025
curl 8.16.0 bumped the enums to long, see
curl/curl#18054

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit 3ed6c8e)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
@VVD
Copy link

VVD commented Sep 30, 2025

Same error with VirtualBox:

/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:702:27: error: assigning to 'curl_proxytype' from incompatible type 'long'
  702 |     pThis->enmProxyType = CURLPROXY_HTTP;
      |                           ^~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:877:33: error: assigning to 'curl_proxytype' from incompatible type 'long'
  877 |                 enmProxyType  = CURLPROXY_HTTP;
      |                                 ^~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:885:33: error: assigning to 'curl_proxytype' from incompatible type 'long'
  885 |                 enmProxyType  = CURLPROXY_HTTPS;
      |                                 ^~~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:795:35: note: expanded from macro 'CURLPROXY_HTTPS'
  795 | #define CURLPROXY_HTTPS           2L /* HTTPS but stick to HTTP/1
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:893:32: error: assigning to 'curl_proxytype' from incompatible type 'long'
  893 |                 enmProxyType = CURLPROXY_SOCKS4;
      |                                ^~~~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:799:35: note: expanded from macro 'CURLPROXY_SOCKS4'
  799 | #define CURLPROXY_SOCKS4          4L /* support added in 7.15.2, enum existed
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:895:32: error: assigning to 'curl_proxytype' from incompatible type 'long'
  895 |                 enmProxyType = CURLPROXY_SOCKS4A;
      |                                ^~~~~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:802:35: note: expanded from macro 'CURLPROXY_SOCKS4A'
  802 | #define CURLPROXY_SOCKS4A         6L /* added in 7.18.0 */
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:897:32: error: assigning to 'curl_proxytype' from incompatible type 'long'
  897 |                 enmProxyType = CURLPROXY_SOCKS5;
      |                                ^~~~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:801:35: note: expanded from macro 'CURLPROXY_SOCKS5'
  801 | #define CURLPROXY_SOCKS5          5L /* added in 7.10 */
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:899:32: error: assigning to 'curl_proxytype' from incompatible type 'long'
  899 |                 enmProxyType = CURLPROXY_SOCKS5_HOSTNAME;
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:803:35: note: expanded from macro 'CURLPROXY_SOCKS5_HOSTNAME'
  803 | #define CURLPROXY_SOCKS5_HOSTNAME 7L /* Use the SOCKS5 protocol but pass along
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:903:32: error: assigning to 'curl_proxytype' from incompatible type 'long'
  903 |                 enmProxyType = CURLPROXY_HTTP;
      |                                ^~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
      |                                   ^~
/tmp/work/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.2/src/VBox/Runtime/generic/http-curl.cpp:2097:12: error: no matching function for call to 'rtHttpUpdateProxyConfig'
 2097 |     return rtHttpUpdateProxyConfig(pThis, CURLPROXY_HTTP, pcszProxy, uPort ? uPort : 1080, pcszProxyUser, pcszProxyPwd);
      |            ^~~~~~~~~~~~~~~~~~~~~~~

https://bugs.freebsd.org/289924

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Oct 1, 2025
…th ftp/curl 8.16.0

kBuild: Compiling VBoxRT - /wrkdirs/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.0/src/VBox/Runtime/generic/http-curl.cpp
/wrkdirs/usr/ports/emulators/virtualbox-ose-72/work/VirtualBox-7.2.0/src/VBox/Runtime/generic/http-curl.cpp:702:27: error: assigning to 'curl_proxytype' from incompatible type 'long'
  702 |     pThis->enmProxyType = CURLPROXY_HTTP;
      |                           ^~~~~~~~~~~~~~
/usr/local/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
      |                                   ^~

Upstream bug report:
curl/curl#18054 (comment)

PR:	289924
mkreisl pushed a commit to xbianonpi/xbian-sources-xbmc that referenced this pull request Oct 8, 2025
curl 8.16.0 bumped the enums to long, see: curl/curl#18054
This fixes the build with curl 8.16+ for the following failure:
	/builds/alpine/aports/community/kodi/src/xbmc-21.2-Omega/xbmc/filesystem/CurlFile.cpp:48:5: error: cannot initialize an array element of type 'curl_proxytype' with an rvalue of type 'long'
	   48 |     CURLPROXY_HTTP,   CURLPROXY_SOCKS4,          CURLPROXY_SOCKS4A,
	      |     ^~~~~~~~~~~~~~
	/usr/include/curl/curl.h:791:35: note: expanded from macro 'CURLPROXY_HTTP'
	  791 | #define CURLPROXY_HTTP            0L /* added in 7.10, new in 7.19.4 default is
	      |                                   ^~
	...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants