From 5e71a7d6b81f12c224cc06eacb6fee8e96b2ac8c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 28 Jun 2022 16:42:32 -0400 Subject: Fix build as C with MSVC --- include/zix/attributes.h | 2 ++ meson.build | 5 ----- meson/suppressions/meson.build | 1 + test/btree_test.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/zix/attributes.h b/include/zix/attributes.h index 3499a7d..3824ce6 100644 --- a/include/zix/attributes.h +++ b/include/zix/attributes.h @@ -57,6 +57,8 @@ # define ZIX_UNUSED(name) #elif defined(__GNUC__) # define ZIX_UNUSED(name) name##_unused __attribute__((__unused__)) +#elif defined(_MSC_VER) +# define ZIX_UNUSED(name) __pragma(warning(suppress:4100)) name #else # define ZIX_UNUSED(name) name #endif diff --git a/meson.build b/meson.build index 92525e8..5b54107 100644 --- a/meson.build +++ b/meson.build @@ -66,11 +66,6 @@ int main(void) { void* mem; posix_memalign(&mem, 8, 8); }''' name: 'posix_memalign').to_int()) endif -# Build as C++ on MSVC -if cc.get_id() == 'msvc' - add_project_arguments(['/TP'], language: ['c']) -endif - ########### # Library # ########### diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build index e5d5cf3..a85cd26 100644 --- a/meson/suppressions/meson.build +++ b/meson/suppressions/meson.build @@ -44,6 +44,7 @@ if is_variable('cc') elif cc.get_id() == 'msvc' c_suppressions += [ + '/wd4114', # same type qualifier used more than once '/wd4191', # unsafe function conversion '/wd4200', # zero-sized array in struct/union '/wd4365', # signed/unsigned mismatch diff --git a/test/btree_test.c b/test/btree_test.c index fb6b769..150a29d 100644 --- a/test/btree_test.c +++ b/test/btree_test.c @@ -220,7 +220,7 @@ test_remove_cases(void) static const uintptr_t s1 = 2u; static const uintptr_t s2 = 255u; - static const size_t n_insertions = s1 * s2 * 1000u; + const size_t n_insertions = s1 * s2 * 1000u; ZixBTree* const t = zix_btree_new(NULL, int_cmp, NULL); -- cgit v1.2.1