Skip to content

msvc: drop exception, make BIT() a bitfield with Visual Studio#20142

Closed
vszakats wants to merge 13 commits intocurl:masterfrom
vszakats:msvcbit
Closed

msvc: drop exception, make BIT() a bitfield with Visual Studio#20142
vszakats wants to merge 13 commits intocurl:masterfrom
vszakats:msvcbit

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jan 1, 2026

Add casts to bool, or use bit type in local variables, where
neccessary to avoid MSVC compiler warnings C4242.

Note: There may remain places needing the above updates, where not
tested in CI, and missed in manual review.

Also:

  • urldata: convert struct field connect_only to bitfield to match its
    counterpart in another struct.
  • rename curl-specific bit type to curl_bit.

Also tried switching over bool arguments to bit, to avoid casts.
I expected it to work, but in practice it resulted in GCC warnings,
possibly where the bitfields ended up using different integer types
depending on how many of them were declared next to each other. That's
my guess at least.

@vszakats vszakats marked this pull request as draft January 1, 2026 15:39
@vszakats vszakats added the feature-window A merge of this requires an open feature window label Jan 2, 2026
@vszakats vszakats changed the title msvc: try building without BIT() hack msvc: make BIT() a bitfield Jan 2, 2026
@vszakats vszakats added the Windows Windows-specific label Jan 2, 2026
@vszakats vszakats changed the title msvc: make BIT() a bitfield msvc: drop exception, make BIT() a bitfield Jan 2, 2026
@vszakats vszakats marked this pull request as ready for review January 2, 2026 03:01
@github-actions github-actions bot added the CI Continuous Integration label Jan 2, 2026
@vszakats vszakats changed the title msvc: drop exception, make BIT() a bitfield msvc: drop exception, make BIT() a bitfield with Visual Studio Jan 2, 2026
@vszakats vszakats force-pushed the msvcbit branch 9 times, most recently from a7f1a2a to daddef4 Compare January 15, 2026 12:20
..\..\lib\url.c(1368): warning C4242: '=' : conversion from 'bit' to 'unsigned char', possible loss of data
https://ci.appveyor.com/project/curlorg/curl/builds/53311748/job/jdbaakbfqagm9149
/home/runner/work/curl/curl/lib/ftp.c:2064:30: error: conversion from ‘bit’ {aka ‘unsigned int’} to ‘unsigned char:1’ may change value [-Werror=conversion]
 2064 |   data->set.include_header = save;
      |                              ^~~~
https://github.com/curl/curl/actions/runs/20649020582/job/59290673546?pr=20142
…penssl passes without cast)"

This reverts commit bd4447b.
src\tool_cb_wrt.c(247,23): error C2220: the following warning is treated as an error
src\tool_cb_wrt.c(247,23): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data
src\tool_operate.c(1141,32): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data
src\tool_operate.c(1142,28): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data
src\tool_operate.c(2148,32): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data
src\tool_operate.c(2149,28): warning C4242: 'initializing': conversion from 'bit' to 'bool', possible loss of data

https://ci.appveyor.com/project/curlorg/curl/builds/53311787/job/yfpcwxuuyl2qq14v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration cmdline tool feature-window A merge of this requires an open feature window tests Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

1 participant