summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-12-29 23:33:38 +0100
committerTyge Løvset <[email protected]>2021-12-29 23:33:38 +0100
commitc0b0275c80752c812df7c52a98a72170d5fc3bcb (patch)
tree530e5080035acdee77434186b9b79cb8c9faff66 /include
parent15e1dd79211828bcb8c2a809837b56397d65c6d9 (diff)
downloadSTC-modified-c0b0275c80752c812df7c52a98a72170d5fc3bcb.tar.gz
STC-modified-c0b0275c80752c812df7c52a98a72170d5fc3bcb.zip
Removed warnings for MS cl -W2 and clang -pedantic -std=c99. No functional changes.
Diffstat (limited to 'include')
-rw-r--r--include/stc/alt/cstr.h2
-rw-r--r--include/stc/cbits.h6
-rw-r--r--include/stc/ccommon.h8
-rw-r--r--include/stc/cmap.h2
-rw-r--r--include/stc/coption.h2
-rw-r--r--include/stc/cpque.h2
-rw-r--r--include/stc/crandom.h7
-rw-r--r--include/stc/csview.h2
8 files changed, 21 insertions, 10 deletions
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h
index 1a9280e8..b9a4ceee 100644
--- a/include/stc/alt/cstr.h
+++ b/include/stc/alt/cstr.h
@@ -399,4 +399,4 @@ STC_DEF void cstr_erase_n(cstr* self, size_t pos, size_t n) {
}
#endif
-#endif \ No newline at end of file
+#endif
diff --git a/include/stc/cbits.h b/include/stc/cbits.h
index a6ee3948..4fa8c146 100644
--- a/include/stc/cbits.h
+++ b/include/stc/cbits.h
@@ -107,9 +107,15 @@ STC_INLINE void cbits_reset(cbits *self, size_t i) {
self->data64[i >> 6] &= ~(1ull << (i & 63));
}
+#ifdef _MSC_VER
+#pragma warning(disable: 4146) // unary minus operator applied to unsigned type
+#endif
STC_INLINE void cbits_set_value(cbits *self, size_t i, bool value) {
self->data64[i >> 6] ^= (-(uint64_t)value ^ self->data64[i >> 6]) & 1ull << (i & 63);
}
+#ifdef _MSC_VER
+#pragma warning(default: 4146)
+#endif
STC_INLINE void cbits_flip(cbits *self, size_t i) {
self->data64[i >> 6] ^= 1ull << (i & 63);
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index b2ae7b97..ce5346e2 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -23,14 +23,14 @@
#ifndef CCOMMON_H_INCLUDED
#define CCOMMON_H_INCLUDED
-#define __USE_MINGW_ANSI_STDIO 1
-
+#define _CRT_SECURE_NO_WARNINGS
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <assert.h>
#if defined(_MSC_VER)
+# pragma warning(disable: 4116 4996) // unnamed type definition in parentheses
# define STC_FORCE_INLINE static __forceinline
#elif defined(__GNUC__) || defined(__clang__)
# define STC_FORCE_INLINE static inline __attribute((always_inline))
@@ -191,12 +191,12 @@ STC_INLINE uint64_t c_default_hash(const void* key, size_t len) {
; b; b != _c_b ? c_free(b) : (void)0, b = NULL)
#define c_apply(v, method, T, ...) do { \
- const T _c_arr[] = __VA_ARGS__; \
+ T _c_arr[] = __VA_ARGS__; \
for (size_t index = 0; index < c_arraylen(_c_arr); ++index) \
{ T v = _c_arr[index]; method; } \
} while (0)
#define c_apply_arr(v, method, T, arr, n) do { \
- const T* _c_arr = arr; size_t _n = n; \
+ T* _c_arr = arr; size_t _n = n; \
for (size_t index = 0; index < _n; ++index) \
{ T v = _c_arr[index]; method; } \
} while (0)
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 2d0b11fc..730fd95e 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -105,7 +105,7 @@ STC_INLINE bool _cx_memb(_empty)(_cx_self m) { return m.size == 0; }
STC_INLINE size_t _cx_memb(_size)(_cx_self m) { return m.size; }
STC_INLINE size_t _cx_memb(_bucket_count)(_cx_self map) { return map.bucket_count; }
STC_INLINE size_t _cx_memb(_capacity)(_cx_self map)
- { return map.bucket_count ? (map.bucket_count - 2)*map.max_load_factor : 0.f; }
+ { return (size_t)(map.bucket_count ? (map.bucket_count - 2)*map.max_load_factor : 0.f); }
STC_INLINE void _cx_memb(_swap)(_cx_self *map1, _cx_self *map2) {c_swap(_cx_self, *map1, *map2); }
STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey)
{ return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; }
diff --git a/include/stc/coption.h b/include/stc/coption.h
index fb61bf2b..08e4fa79 100644
--- a/include/stc/coption.h
+++ b/include/stc/coption.h
@@ -177,4 +177,4 @@ static int coption_get(coption *opt, int argc, char *argv[],
return optc;
}
-#endif \ No newline at end of file
+#endif
diff --git a/include/stc/cpque.h b/include/stc/cpque.h
index bf519125..2ca57289 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -158,4 +158,4 @@ _cx_memb(_push)(_cx_self* self, _cx_value value) {
#endif
#include "template.h"
-#define CPQUE_H_INCLUDED \ No newline at end of file
+#define CPQUE_H_INCLUDED
diff --git a/include/stc/crandom.h b/include/stc/crandom.h
index eef4b6a4..5b4e9f3a 100644
--- a/include/stc/crandom.h
+++ b/include/stc/crandom.h
@@ -172,7 +172,9 @@ STC_DEF stc32_t stc32_with_seq(uint32_t seed, uint32_t seq) {
for (int i = 0; i < 6; ++i) stc32_rand(&rng);
return rng;
}
-
+#ifdef _MSC_VER
+#pragma warning(disable: 4146) // unary minus operator applied to unsigned type
+#endif
/* Init unbiased uniform uint RNG with bounds [low, high] */
STC_DEF stc64_uniform_t stc64_uniform_init(int64_t low, int64_t high) {
stc64_uniform_t dist = {low, (uint64_t) (high - low + 1)};
@@ -185,6 +187,9 @@ STC_DEF stc32_uniform_t stc32_uniform_init(int32_t low, int32_t high) {
dist.threshold = (uint32_t)(-dist.range) % dist.range;
return dist;
}
+#ifdef _MSC_VER
+#pragma warning(default: 4146)
+#endif
/* Init uniform distributed float64 RNG, range [low, high). */
STC_DEF stc64_uniformf_t stc64_uniformf_init(double low, double high) {
diff --git a/include/stc/csview.h b/include/stc/csview.h
index c4844bfb..c8d8eda5 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -149,4 +149,4 @@ csview_token(csview sv, csview sep, size_t* start) {
}
#endif
-#endif \ No newline at end of file
+#endif