Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
openssl: Fix compilation on Windows when ngtcp2 is enabled #5606
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
That include happens here.
In order to solve these conflicts and fix the compile issues when
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: ``` #define X509_NAME ((LPCSTR) 7) #define OCSP_REQUEST ((LPCSTR) 66) #define OCSP_RESPONSE ((LPCSTR) 67) ``` Which conflict with these OpenSSL types and cause compile errors: ``` typedef struct X509_name_st X509_NAME; typedef struct ocsp_request_st OCSP_REQUEST; typedef struct ocsp_response_st OCSP_RESPONSE; ``` OpenSSL headers already try to avoid these conflicts by [undefining these Windows macros](https://github.com/openssl/openssl/blob/15dfa0/include/openssl/types.h#L71-L78). 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 before `wincrypt.h`. If `ngtcp2` is enabled, for example, then the `urldata.h` include ends up including OpenSSL headers transitively like this: ``` Note: including file: urldata.h Note: including file: quic.h Note: including file: vquic/ngtcp2.h Note: including file: openssl/ssl.h ``` That include happens [here](https://github.com/curl/curl/blob/14c17a/lib/vquic/ngtcp2.h#L32). In order to solve these conflicts and fix the compile issues when `ngtcp2` is enabled, we need to move the `wincrypt.h` include as early as possible.