diff options
| author | Tyge Løvset <[email protected]> | 2020-09-14 11:43:15 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-09-14 11:43:15 +0200 |
| commit | ab21f83c4af4f2b628ce36ad03f5c78fbb11a06a (patch) | |
| tree | 900c1ba2db1f861ceca40a3e37a3e644aeaee954 | |
| parent | 1dd8d2ef2b5fd86bd500ab01c52f7e4a3bd9df60 (diff) | |
| download | STC-modified-ab21f83c4af4f2b628ce36ad03f5c78fbb11a06a.tar.gz STC-modified-ab21f83c4af4f2b628ce36ad03f5c78fbb11a06a.zip | |
Removed warnings. clang, vs.
| -rw-r--r-- | examples/complex.c | 2 | ||||
| -rw-r--r-- | examples/ex_gaussian.c | 2 | ||||
| -rw-r--r-- | examples/heap.c | 4 | ||||
| -rw-r--r-- | examples/queue.c | 3 | ||||
| -rw-r--r-- | stc/cdefs.h | 1 | ||||
| -rw-r--r-- | stc/cmap.h | 2 | ||||
| -rw-r--r-- | stc/crandom.h | 9 | ||||
| -rw-r--r-- | 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<N; ++i)
- cvec_f_push_back(&pq, crand_i32(&pcg));
+ cvec_f_push_back(&pq, (float) crand_i32(&pcg));
cpqueue_f_build(&pq);
printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
@@ -34,7 +34,7 @@ int main() pcg = crand_rng32_init(seed);
start = clock();
for (int i=0; i<N; ++i)
- cpqueue_f_push(&pq, crand_i32(&pcg));
+ cpqueue_f_push(&pq, (float) crand_i32(&pcg));
printf("pushed PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
for (int i=0; i<M; ++i)
diff --git a/examples/queue.c b/examples/queue.c index 25aefd09..5bac7535 100644 --- a/examples/queue.c +++ b/examples/queue.c @@ -26,7 +26,6 @@ int main() { else
--n, cqueue_i_pop(&queue);
}
- printf("%d\n", n);
- printf("%zu\n", n, cqueue_i_size(queue));
+ printf("%d, %zu\n", n, cqueue_i_size(queue));
cqueue_i_destroy(&queue);
}
diff --git a/stc/cdefs.h b/stc/cdefs.h index 01f1110c..bc7b0e1f 100644 --- a/stc/cdefs.h +++ b/stc/cdefs.h @@ -63,7 +63,6 @@ #define c_new(T) ((T *) malloc(sizeof(T)))
#define c_new_n(T, n) ((T *) malloc(sizeof(T) * (n)))
-#define c_assert(cond, msg) assert((msg, cond))
#define c_static_assert(cond, msg) typedef char static_assert_##msg[(cond) ? 1 : -1]
#define c_max_alloca (512)
@@ -248,7 +248,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; STC_API ctype##_##X##_mapped_t* \
ctype##_##X##_at(const ctype##_##X* self, RawKey rawKey) { \
ctype##_bucket_t b = ctype##_##X##_bucket(self, &rawKey); \
- c_assert(self->_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
@@ -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; \
} \
\
|
