diff --git a/CMakeLists.txt b/CMakeLists.txt index 7557743..c22e703 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option(COUNTLY_USE_CUSTOM_HTTP "Use a custom HTTP library" OFF) option(COUNTLY_USE_SQLITE "Use SQLite" OFF) option(COUNTLY_BUILD_TESTS "Build test programs" OFF) -if (NOT BUILD_SHARED_LIBS AND NOT COUNTLY_CUSTOM_HTTP) +if (NOT WIN32 AND NOT BUILD_SHARED_LIBS AND NOT COUNTLY_CUSTOM_HTTP) message(FATAL_ERROR "You must provide a custom HTTP function when compiling statically.") endif() @@ -33,6 +33,13 @@ target_link_libraries(countly Threads::Threads) target_include_directories(countly PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/json/include) +if (APPLE) + set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl") +endif() +find_package(OpenSSL REQUIRED) +target_include_directories(countly PRIVATE ${OPENSSL_INCLUDE_DIR}) +target_link_libraries(countly ${OPENSSL_LIBRARIES}) + if(COUNTLY_USE_CUSTOM_HTTP) target_compile_definitions(countly PRIVATE COUNTLY_USE_CUSTOM_HTTP) elseif(NOT WIN32) @@ -47,12 +54,6 @@ if(COUNTLY_USE_SQLITE) find_package(Sqlite3) target_include_directories(countly PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/sqlite) target_link_libraries(countly sqlite3) - if (APPLE) - set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl") - endif() - find_package(OpenSSL REQUIRED) - target_include_directories(countly PRIVATE ${OPENSSL_INCLUDE_DIRS}) - target_link_libraries(countly ${OPENSSL_LIBRARIES}) endif() if(COUNTLY_BUILD_TESTS) diff --git a/include/countly.hpp b/include/countly.hpp index cbd555f..ccf1317 100644 --- a/include/countly.hpp +++ b/include/countly.hpp @@ -15,6 +15,10 @@ #include "nlohmann/json.hpp" using json = nlohmann::json; +#ifdef _WIN32 +#undef ERROR +#endif + #define COUNTLY_SDK_NAME "cpp-native-unknown" #define COUNTLY_SDK_VERSION "0.1.0" #define COUNTLY_API_VERSION "19.8.0" @@ -136,6 +140,8 @@ class Countly { void SetPath(const std::string& path) { #ifdef COUNTLY_USE_SQLITE setDatabasePath(path); +#elif defined _WIN32 + UNREFERENCED_PARAMETER(path); #endif } diff --git a/src/countly.cpp b/src/countly.cpp index 18df26f..aa0cf2e 100644 --- a/src/countly.cpp +++ b/src/countly.cpp @@ -17,6 +17,7 @@ using json = nlohmann::json; #ifdef _WIN32 #include "Windows.h" #include "WinHTTP.h" +#undef ERROR #pragma comment(lib, "winhttp.lib") #else #include "curl/curl.h" @@ -694,7 +695,7 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) { } if (hRequest) { - bool ok = WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, use_post ? data.c_str() : WINHTTP_NO_REQUEST_DATA, use_post ? data.size() : 0, 0, nullptr) != 0; + bool ok = WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, use_post ? (LPVOID)data.data() : WINHTTP_NO_REQUEST_DATA, use_post ? data.size() : 0, 0, 0) != 0; if (ok) { ok = WinHttpReceiveResponse(hRequest, NULL); if (ok) {