openssl: Fix compilation on Windows when ngtcp2 is enabled #5606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
wincrypt.h
Windows header defines a number of preprocessor macros that conflict with identically named OpenSSL types. For example, it defines the following macros:Which conflict with these OpenSSL types and cause compile errors:
OpenSSL headers already try to avoid these conflicts by undefining these Windows macros. However, that requires that
wincrypt.h
is included before any OpenSSL header.In curl's
vtls/openssl.c
file, there is at least one configuration where an OpenSSL header is included beforewincrypt.h
. Ifngtcp2
is enabled, for example, then theurldata.h
include ends up including OpenSSL headers transitively like this:That include happens here.
In order to solve these conflicts and fix the compile issues when
ngtcp2
is enabled, we need to move thewincrypt.h
include as early as possible.