From ab21f83c4af4f2b628ce36ad03f5c78fbb11a06a Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 14 Sep 2020 11:43:15 +0200 Subject: Removed warnings. clang, vs. --- examples/complex.c | 2 +- examples/ex_gaussian.c | 2 +- examples/heap.c | 4 ++-- examples/queue.c | 3 +-- stc/cdefs.h | 1 - stc/cmap.h | 2 +- stc/crandom.h | 9 +++++++++ stc/cvec.h | 2 +- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/complex.c b/examples/complex.c index 25a59eff..151824e2 100644 --- a/examples/complex.c +++ b/examples/complex.c @@ -23,7 +23,7 @@ int main() { // Put in some data. cmap_g listMap = cmap_ini; - *carray2f_at(&table, y, x) = 3.1415927; // table[y][x] + *carray2f_at(&table, y, x) = 3.1415927f; // table[y][x] clist_y_push_back(&tableList, table); cmap_g_put(&listMap, tableKey, tableList); cmap_s_put(&myMap, strKey, listMap); diff --git a/examples/ex_gaussian.c b/examples/ex_gaussian.c index cd44e78a..8751ffa0 100644 --- a/examples/ex_gaussian.c +++ b/examples/ex_gaussian.c @@ -31,7 +31,7 @@ int main() // Create histogram map cmap_i mhist = cmap_ini; for (size_t i = 0; i < N; ++i) { - int index = round( crand_normal_f64(&rng, &dist) ); + int index = (int) round( crand_normal_f64(&rng, &dist) ); cmap_i_emplace(&mhist, index, 0).item->value += 1; } diff --git a/examples/heap.c b/examples/heap.c index 5917dd30..a281de01 100644 --- a/examples/heap.c +++ b/examples/heap.c @@ -18,7 +18,7 @@ int main() pcg = crand_rng32_init(seed); clock_t start = clock(); for (int i=0; i_hashx[b.idx], "cmap_at()"); \ + assert(self->_hashx[b.idx]); \ return &self->table[b.idx].value; \ } \ STC_INLINE ctype##_##X##_result_t \ diff --git a/stc/crandom.h b/stc/crandom.h index 1a593d82..d0d9df36 100644 --- a/stc/crandom.h +++ b/stc/crandom.h @@ -132,6 +132,11 @@ STC_API double crand_normal_f64(crand_rng64_t* rng, crand_normal_f64_t* dist); #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) +#if defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable: 4146) +#endif + /* PRNG PCG32 https://www.pcg-random.org/download.html */ STC_API crand_rng32_t crand_rng32_with_seq(uint64_t seed, uint64_t seq) { crand_rng32_t rng = {{0u, (seq << 1u) | 1u}}; /* inc must be odd */ @@ -197,5 +202,9 @@ STC_API double crand_normal_f64(crand_rng64_t* rng, crand_normal_f64_t* dist) { return (u1 * m) * dist->stddev + dist->mean; } +#if defined(_MSC_VER) + #pragma warning(pop) +#endif + #endif #endif diff --git a/stc/cvec.h b/stc/cvec.h index ea7cd923..74be62e7 100644 --- a/stc/cvec.h +++ b/stc/cvec.h @@ -165,7 +165,7 @@ cvec_##X##_back(cvec_##X* self) {return self->data + _cvec_size(self) - 1;} \ STC_INLINE Value* \ cvec_##X##_at(cvec_##X* self, size_t i) { \ - c_assert(i < cvec_size(*self), "cvec_at()"); \ + assert(i < cvec_size(*self)); \ return self->data + i; \ } \ \ -- cgit v1.2.3