summaryrefslogtreecommitdiffhomepage
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
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.
-rw-r--r--examples/books.c2
-rw-r--r--examples/box2.c2
-rw-r--r--examples/cpque.c4
-rw-r--r--examples/csmap_insert.c2
-rw-r--r--examples/cstr_match.c2
-rw-r--r--examples/inits.c2
-rw-r--r--examples/list.c2
-rw-r--r--examples/list_splice.c2
-rw-r--r--examples/mapmap.c2
-rw-r--r--examples/new_deq.c2
-rw-r--r--examples/new_list.c2
-rw-r--r--examples/new_map.c2
-rw-r--r--examples/new_queue.c2
-rw-r--r--examples/new_sptr.c2
-rw-r--r--examples/new_vec.c2
-rw-r--r--examples/option_mkdir.c2
-rw-r--r--examples/phonebook.c2
-rw-r--r--examples/sidebyside.cpp2
-rw-r--r--examples/splitstr.c2
-rw-r--r--examples/stack.c2
-rw-r--r--examples/sview_split.c2
-rw-r--r--examples/vikings.c2
-rw-r--r--examples/words.c2
-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
31 files changed, 45 insertions, 34 deletions
diff --git a/examples/books.c b/examples/books.c
index f9340679..8ddce634 100644
--- a/examples/books.c
+++ b/examples/books.c
@@ -57,4 +57,4 @@ int main()
printf("%s: \"%s\"\n", _.book.str, _.review.str);
}
}
-} \ No newline at end of file
+}
diff --git a/examples/box2.c b/examples/box2.c
index fd76f8eb..d5905877 100644
--- a/examples/box2.c
+++ b/examples/box2.c
@@ -85,4 +85,4 @@ int main(void) {
printf("Unboxed point occupies %zu bytes on the stack\n",
sizeof(unboxed_point));
}
-} \ No newline at end of file
+}
diff --git a/examples/cpque.c b/examples/cpque.c
index d3ad2d0c..048d9b51 100644
--- a/examples/cpque.c
+++ b/examples/cpque.c
@@ -37,11 +37,11 @@ int main()
print_queue(q);
icmp_fn = imin_cmp;
- c_apply_arr(v, ipque_push(&q2, v), int, data, n);
+ c_apply_arr(v, ipque_push(&q2, v), const int, data, n);
print_queue(q2);
icmp_fn = imix_cmp;
- c_apply_arr(v, ipque_push(&q3, v), int, data, n);
+ c_apply_arr(v, ipque_push(&q3, v), const int, data, n);
print_queue(q3);
}
}
diff --git a/examples/csmap_insert.c b/examples/csmap_insert.c
index 5f5813a8..2a69a8f7 100644
--- a/examples/csmap_insert.c
+++ b/examples/csmap_insert.c
@@ -105,4 +105,4 @@ int main()
print_ii(m4);
puts("");
}
-} \ No newline at end of file
+}
diff --git a/examples/cstr_match.c b/examples/cstr_match.c
index dc1423d7..db5b3ecf 100644
--- a/examples/cstr_match.c
+++ b/examples/cstr_match.c
@@ -12,4 +12,4 @@ int main()
printf("ends_with: %d\n", cstr_ends_with(ss, ".jpg"));
printf("ends_with: %d\n", cstr_ends_with(ss, ".JPG"));
}
-} \ No newline at end of file
+}
diff --git a/examples/inits.c b/examples/inits.c
index 4fdc17d5..78eced11 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -110,4 +110,4 @@ int main(void)
printf("(%d %d) ", i.ref->x, i.ref->y);
puts("");
}
-} \ No newline at end of file
+}
diff --git a/examples/list.c b/examples/list.c
index 84f4e24c..4d177b3b 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -53,4 +53,4 @@ int main() {
printf(" %g", *i.ref);
puts("");
}
-} \ No newline at end of file
+}
diff --git a/examples/list_splice.c b/examples/list_splice.c
index 0738e9d3..754ec6fb 100644
--- a/examples/list_splice.c
+++ b/examples/list_splice.c
@@ -35,4 +35,4 @@ int main ()
print_ilist("list1:", list1);
print_ilist("list2:", list2);
}
-} \ No newline at end of file
+}
diff --git a/examples/mapmap.c b/examples/mapmap.c
index 61b55493..f0bf31a8 100644
--- a/examples/mapmap.c
+++ b/examples/mapmap.c
@@ -64,4 +64,4 @@ int main(void)
c_auto (Stack, s) printf("found: %zu\n", Stack_size(s = contains(&map, "Serena Bath")));
puts("Done");
}
-} \ No newline at end of file
+}
diff --git a/examples/new_deq.c b/examples/new_deq.c
index 57224869..9022c377 100644
--- a/examples/new_deq.c
+++ b/examples/new_deq.c
@@ -58,4 +58,4 @@ int main()
{
cdeq_str_emplace_back(&svec, "Hello, friend");
}
-} \ No newline at end of file
+}
diff --git a/examples/new_list.c b/examples/new_list.c
index b6718d34..2b6b4636 100644
--- a/examples/new_list.c
+++ b/examples/new_list.c
@@ -56,4 +56,4 @@ int main()
c_auto (clist_str, slst)
clist_str_emplace_back(&slst, "Hello, friend");
-} \ No newline at end of file
+}
diff --git a/examples/new_map.c b/examples/new_map.c
index f641a0eb..97fce008 100644
--- a/examples/new_map.c
+++ b/examples/new_map.c
@@ -68,4 +68,4 @@ int main()
c_foreach (i, cset_str, sset)
printf(" %s\n", i.ref->str);
}
-} \ No newline at end of file
+}
diff --git a/examples/new_queue.c b/examples/new_queue.c
index 9219a1b4..718c025f 100644
--- a/examples/new_queue.c
+++ b/examples/new_queue.c
@@ -41,4 +41,4 @@ int main() {
}
printf("after: size %zu, capacity %zu\n", cqueue_int_size(Q), cqueue_int_capacity(Q));
}
-} \ No newline at end of file
+}
diff --git a/examples/new_sptr.c b/examples/new_sptr.c
index 09bb7137..3a038629 100644
--- a/examples/new_sptr.c
+++ b/examples/new_sptr.c
@@ -52,4 +52,4 @@ int main(void) {
printf(" (%d, uses %ld)", *i.ref->get, *i.ref->use_count);
puts("");
}
-} \ No newline at end of file
+}
diff --git a/examples/new_vec.c b/examples/new_vec.c
index c5570942..b0382121 100644
--- a/examples/new_vec.c
+++ b/examples/new_vec.c
@@ -56,4 +56,4 @@ int main()
cvec_str svec = cvec_str_init();
cvec_str_emplace_back(&svec, "Hello, friend");
cvec_str_drop(&svec);
-} \ No newline at end of file
+}
diff --git a/examples/option_mkdir.c b/examples/option_mkdir.c
index b9f4ddea..3c4b8e12 100644
--- a/examples/option_mkdir.c
+++ b/examples/option_mkdir.c
@@ -91,4 +91,4 @@ int main(int argc, char* argv[])
args.mode? args.mode:"",
args.parent, args.verbose,
args.context? args.context:"");
-} \ No newline at end of file
+}
diff --git a/examples/phonebook.c b/examples/phonebook.c
index ccc10eaf..eeb1d3b8 100644
--- a/examples/phonebook.c
+++ b/examples/phonebook.c
@@ -81,4 +81,4 @@ int main(int argc, char **argv)
print_phone_book(phone_book);
}
puts("done");
-} \ No newline at end of file
+}
diff --git a/examples/sidebyside.cpp b/examples/sidebyside.cpp
index 435b37f6..d765fb91 100644
--- a/examples/sidebyside.cpp
+++ b/examples/sidebyside.cpp
@@ -45,4 +45,4 @@ int main() {
printf("%d, %d\n", i.ref->first, i.ref->second);
puts("");
}
-} \ No newline at end of file
+}
diff --git a/examples/splitstr.c b/examples/splitstr.c
index 75ee3022..81688ec7 100644
--- a/examples/splitstr.c
+++ b/examples/splitstr.c
@@ -34,4 +34,4 @@ int main()
c_autovar (cvec_str v = string_split(c_sv("Split,this,,string,now,"), c_sv(",")), cvec_str_drop(&v))
c_foreach (i, cvec_str, v)
printf("[%s]\n", i.ref->str);
-} \ No newline at end of file
+}
diff --git a/examples/stack.c b/examples/stack.c
index dac0112e..f392ecd1 100644
--- a/examples/stack.c
+++ b/examples/stack.c
@@ -27,4 +27,4 @@ int main() {
puts("");
printf("top: %d\n", *cstack_i_top(&stack));
}
-} \ No newline at end of file
+}
diff --git a/examples/sview_split.c b/examples/sview_split.c
index ed0365ec..bd5c26d5 100644
--- a/examples/sview_split.c
+++ b/examples/sview_split.c
@@ -16,4 +16,4 @@ int main()
y = cstr_from_v(year), m = cstr_from_v(month), d = cstr_from_v(day);
printf("%s, %s, %s\n", y.str, m.str, d.str);
}
-} \ No newline at end of file
+}
diff --git a/examples/vikings.c b/examples/vikings.c
index 5acafb3f..943b1f36 100644
--- a/examples/vikings.c
+++ b/examples/vikings.c
@@ -66,4 +66,4 @@ int main()
printf("%s of %s has %d hp\n", _.viking.name.str, _.viking.country.str, _.hp);
}
}
-} \ No newline at end of file
+}
diff --git a/examples/words.c b/examples/words.c
index 568f9557..852207a9 100644
--- a/examples/words.c
+++ b/examples/words.c
@@ -65,4 +65,4 @@ int main() {
int main() {
main1();
}
-#endif \ No newline at end of file
+#endif
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