cpr
cpr copied to clipboard
cpr.h includes windows.h on Windows (again)
See https://github.com/libcpr/cpr/issues/700 for the first bug report on this issue. It was fixed for a while, but unfortunately https://github.com/libcpr/cpr/commit/c0a412230be7ce1fced4b8c3a6fb2b8b9f7dd746 introduced a new inclusion of curl.h, so the problem appeared again.
Here's the chain:
-
cpr/cpr.h
->cpr/cookies.h
->cpr/curlholder.h
->curl/curl.h
Description
See https://github.com/libcpr/cpr/issues/700.
Expected Behavior
See https://github.com/libcpr/cpr/issues/700.
Actual Behavior
See https://github.com/libcpr/cpr/issues/700.
Possible Fix
See https://github.com/libcpr/cpr/issues/700.
Steps to Reproduce
See https://github.com/libcpr/cpr/issues/700.
Context
See https://github.com/libcpr/cpr/issues/700.
Your Environment
- Version used: 1.8.1
- Where did you get it from (e.g. conan, vcpkg, master, ...): conan
- Operating System and version: Windows 10 Pro
- Link to a small example:
void CopyFile() { /*...*/ }
#include "cpr/cpr.h"
int main() {
CopyFile(); // compiler error
}
Thanks for the heads up on this one. I will have a look at it shortly!
I don't think this is something we can fix if you include cpr/cpr.h
since we require the curl.h
include inside cpr/curlholder.h
for the CURL
type, which is not being able to be forward declared.
I have created a PR to reduce the number of transitive curl.h includes in cpr here: https://github.com/libcpr/cpr/pull/758
Could you please try this branch and do not include cpr/cpr.h
, but instead try cpr/api.h
.
Ping @cschreib-ibex
Sorry, I was on honeymoon! I just gave it a go, and it seems there is still an issue:
-
cpr/api.h
->cpr/response.h
->cpr/ssl_options.h
->curl/curl.h
It looks like the include tocpr/ssl_options.h
can just be removed fromresponse.h
. -
cpr/api.h
->cpr/session.h
->cpr/ssl_options.h
->curl/curl.h
This one cannot just be removed.session.h
needs forward declarations for
struct VerifySsl;
struct SslOptions;
Then there's a reference to the CURLcode
type; I don't know if that can be forward-declared?
Response Complete(CURLcode curl_error);
Alternatively, includes to ssl_options.h
can remain unchanged, but some of the code inside ssl_options.h
can be split out into a .cpp
, so the header does not need to include curl.h
.