cpr
cpr copied to clipboard
Compatiblity for OSX without filesystem.h
There is a long story of pain with filesystem.h on OSX using CLang, so for those who still wants to compile cpr - this patch could be useful. Surely, boost is not the optimal decision, specially if project doesn't use it. Also there are some failed tests, that requires additional research and fixes.
Tested on OSX 10.13 Clang LLVM 10.0.1: 3 tests failed out of 23:
- cpr_post_tests (UrlEncodedPostTests.UrlPostAsyncSingleTest)
- cpr_head_tests (HeadTests.BasicHeadAsyncTest)
- cpr_options_tests (OptionsTests.AsyncBaseUrlTest, OptionsTests.AsyncSpecificUrlTest)
Yes, I see:
Checking /home/runner/work/cpr/cpr/cpr/file.cpp ... /home/runner/work/cpr/cpr/include/cpr/filesystem.h:11:0: error: failed to evaluate #elif condition, division/modulo by zero [preprocessorErrorDirective] #elif __has_include(<boost/filesystem.hpp>) ^ make[2]: *** [cpr/CMakeFiles/cpr.dir/build.make:216: cpr/CMakeFiles/cpr.dir/file.cpp.o] Error 1
Looks strange. Checking. Thank you!
With __has_include("boost/filesystem.hpp")
cppcheck passed, but compilation failed.
As workaround for the issue with cppcheck, this line could be suppressed:
//cppcheck-suppress preprocessorErrorDirective
#elif __has_include(<boost/filesystem.hpp>)
and cppcheck should be started with --inline-suppr
argument.
cppcheck should be fine now, since --inline-suppr
already added in cmake/cppcheck.cmake
Would you mind creating a option for this. E.g. CPR_USE_BOOST_FILESYSTEM
yes, working on it. do I need to switch to another branch for PR while WIP (draft)?
No, there is no need for a new branch
All looks good. Thanks for your work (and sorry for the many iterations). I will merge after the CI passes.
Great! Thank you! There are possible bugs on using fs::file still (e.g. suspecting multiperform.h for Download) - not found it yet, tracing/debugging in spare time.