diff --git a/CMakeLists.txt b/CMakeLists.txt index 24d489a92d..c83d06c6a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,7 +253,8 @@ if(MSVC) endif() # using `/Wall` is not feasible, as it spews tons of warnings from windows headers - target_compile_options(sentry PRIVATE $) + # supress C5105, introduced in VS 16.8, which breaks on the Windows SDKs own `winbase.h` header + target_compile_options(sentry PRIVATE $) # ignore all warnings for mpack set_source_files_properties( "${PROJECT_SOURCE_DIR}/vendor/mpack.c" @@ -456,6 +457,10 @@ if(SENTRY_BUILD_EXAMPLES) add_executable(sentry_example examples/example.c) target_link_libraries(sentry_example PRIVATE sentry) + if(MSVC) + target_compile_options(sentry_example PRIVATE $) + endif() + # set static runtime if enabled if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC) set_property(TARGET sentry_example PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") diff --git a/examples/example.c b/examples/example.c index ea6776c42b..392675a586 100644 --- a/examples/example.c +++ b/examples/example.c @@ -1,3 +1,9 @@ +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# define NOMINMAX +# define _CRT_SECURE_NO_WARNINGS +#endif + #include "sentry.h" #include #include @@ -5,7 +11,7 @@ #include #ifdef SENTRY_PLATFORM_WINDOWS -# include +# include # define sleep_s(SECONDS) Sleep((SECONDS)*1000) #else # include diff --git a/external/crashpad b/external/crashpad index a0b37e180d..fba97d0d55 160000 --- a/external/crashpad +++ b/external/crashpad @@ -1 +1 @@ -Subproject commit a0b37e180de96fb1dd22a26ce1bc847f4dd21824 +Subproject commit fba97d0d5556ebd2dc94d183304ff990d2462820 diff --git a/src/path/sentry_path_windows.c b/src/path/sentry_path_windows.c index 1b13e33763..1460775c8e 100644 --- a/src/path/sentry_path_windows.c +++ b/src/path/sentry_path_windows.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -125,7 +124,13 @@ sentry__path_dir(const sentry_path_t *path) if (!dir_path) { return NULL; } - PathRemoveFileSpecW(dir_path->path); + + // find the filename part and truncate just in front of it if possible + sentry_pathchar_t *filename + = (sentry_pathchar_t *)sentry__path_filename(dir_path); + if (filename > dir_path->path) { + *(filename - 1) = L'\0'; + } return dir_path; } @@ -216,7 +221,7 @@ sentry__path_filename(const sentry_path_t *path) size_t idx = wcslen(s); while (true) { - if (s[idx] == L'/' || s[idx] == '\\') { + if (s[idx] == L'/' || s[idx] == L'\\') { ptr = s + idx + 1; break; } diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index d5c388f1f0..9e170dcfb9 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -67,6 +67,10 @@ if(MINGW) ) endif() +if(MSVC) + target_compile_options(sentry_test_unit PRIVATE $) +endif() + # set static runtime if enabled if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC) set_property(TARGET sentry_test_unit PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>")