diff options
| author | Tyge Løvset <[email protected]> | 2022-10-14 16:02:25 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-10-14 16:02:25 +0200 |
| commit | d26fd02b70b9f091c2bcfa350e420f74c1f023f8 (patch) | |
| tree | 7ca2902ee839cb1ce7bfc3333f6ead2e4ea39ef2 /examples | |
| parent | 54c08dc031c622e78dc134353690ed359b9173d8 (diff) | |
| download | STC-modified-d26fd02b70b9f091c2bcfa350e420f74c1f023f8.tar.gz STC-modified-d26fd02b70b9f091c2bcfa350e420f74c1f023f8.zip | |
Replaced PRIuMAX with new c_zu macro in examples. "%zu" is not supported by mingw64 and PRIuMAX is not a replacement for "zu".
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/birthday.c | 4 | ||||
| -rw-r--r-- | examples/bits.c | 12 | ||||
| -rw-r--r-- | examples/bits2.c | 4 | ||||
| -rw-r--r-- | examples/books.c | 2 | ||||
| -rw-r--r-- | examples/box2.c | 12 | ||||
| -rw-r--r-- | examples/complex.c | 2 | ||||
| -rw-r--r-- | examples/csmap_erase.c | 4 | ||||
| -rw-r--r-- | examples/csmap_find.c | 2 | ||||
| -rw-r--r-- | examples/cstr_match.c | 4 | ||||
| -rw-r--r-- | examples/demos.c | 10 | ||||
| -rw-r--r-- | examples/new_queue.c | 4 | ||||
| -rw-r--r-- | examples/prime.c | 4 | ||||
| -rw-r--r-- | examples/priority.c | 2 | ||||
| -rw-r--r-- | examples/queue.c | 2 | ||||
| -rw-r--r-- | examples/random.c | 6 | ||||
| -rw-r--r-- | examples/sso_map.c | 2 |
16 files changed, 38 insertions, 38 deletions
diff --git a/examples/birthday.c b/examples/birthday.c index 8b23f7ab..ce7a7edb 100644 --- a/examples/birthday.c +++ b/examples/birthday.c @@ -24,7 +24,7 @@ static void test_repeats(void) c_forloop (i, N) { uint64_t k = stc64_rand(&rng) & mask; int v = cmap_ic_insert(&m, k, 0).ref->second += 1; - if (v > 1) printf("repeated value %" PRIuMAX " (%d) at 2^%d\n", k, v, (int) log2((double) i)); + if (v > 1) printf("repeated value %" c_zu " (%d) at 2^%d\n", k, v, (int) log2((double) i)); } } } @@ -52,7 +52,7 @@ void test_distribution(void) sum /= map.size; c_foreach (i, cmap_x, map) { - printf("%4u: %" PRIuMAX " - %" PRIuMAX ": %11.8f\n", i.ref->first, i.ref->second, sum, (1 - (double) i.ref->second / sum)); + printf("%4u: %" c_zu " - %" c_zu ": %11.8f\n", i.ref->first, i.ref->second, sum, (1 - (double) i.ref->second / sum)); } } } diff --git a/examples/bits.c b/examples/bits.c index c89ad7d3..505be497 100644 --- a/examples/bits.c +++ b/examples/bits.c @@ -4,11 +4,11 @@ int main() { c_with (cbits set = cbits_with_size(23, true), cbits_drop(&set)) { - printf("count %" PRIuMAX ", %" PRIuMAX "\n", cbits_count(&set), cbits_size(&set)); + printf("count %" c_zu ", %" c_zu "\n", cbits_count(&set), cbits_size(&set)); cbits s1 = cbits_from("1110100110111"); char buf[256]; cbits_to_str(&s1, buf, 0, -1); - printf("buf: %s: %" PRIuMAX "\n", buf, cbits_count(&s1)); + printf("buf: %s: %" c_zu "\n", buf, cbits_count(&s1)); cbits_drop(&s1); cbits_reset(&set, 9); @@ -16,7 +16,7 @@ int main() c_autobuf (str, char, cbits_size(&set) + 1) printf(" str: %s\n", cbits_to_str(&set, str, 0, -1)); - printf("%4" PRIuMAX ": ", cbits_size(&set)); + printf("%4" c_zu ": ", cbits_size(&set)); c_forloop (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts(""); @@ -26,12 +26,12 @@ int main() cbits_resize(&set, 93, false); cbits_resize(&set, 102, true); cbits_set_value(&set, 99, false); - printf("%4" PRIuMAX ": ", cbits_size(&set)); + printf("%4" c_zu ": ", cbits_size(&set)); c_forloop (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts("\nIterate:"); - printf("%4" PRIuMAX ": ", cbits_size(&set)); + printf("%4" c_zu ": ", cbits_size(&set)); c_forloop (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts(""); @@ -53,7 +53,7 @@ int main() puts(""); cbits_set_all(&set, false); - printf("%4" PRIuMAX ": ", cbits_size(&set)); + printf("%4" c_zu ": ", cbits_size(&set)); c_forloop (i, cbits_size(&set)) printf("%d", cbits_test(&set, i)); puts(""); diff --git a/examples/bits2.c b/examples/bits2.c index 0161376b..c2c1f6be 100644 --- a/examples/bits2.c +++ b/examples/bits2.c @@ -9,10 +9,10 @@ int main() { Bits s1 = Bits_from("1110100110111"); - printf("size %" PRIuMAX "\n", Bits_size(&s1)); + printf("size %" c_zu "\n", Bits_size(&s1)); char buf[256]; Bits_to_str(&s1, buf, 0, -1); - printf("buf: %s: count=%" PRIuMAX "\n", buf, Bits_count(&s1)); + printf("buf: %s: count=%" c_zu "\n", buf, Bits_count(&s1)); Bits_reset(&s1, 8); c_autobuf (str, char, Bits_size(&s1) + 1) diff --git a/examples/books.c b/examples/books.c index 90d2d529..e1962a92 100644 --- a/examples/books.c +++ b/examples/books.c @@ -32,7 +32,7 @@ int main() // When collections store owned values (String), they can still be // queried using references (&str). if (cmap_str_contains(&book_reviews, "Les Misérables")) { - printf("We've got %" PRIuMAX " reviews, but Les Misérables ain't one.", + printf("We've got %" c_zu " reviews, but Les Misérables ain't one.", cmap_str_size(&book_reviews)); } diff --git a/examples/box2.c b/examples/box2.c index 28b4acff..13dc8c26 100644 --- a/examples/box2.c +++ b/examples/box2.c @@ -64,22 +64,22 @@ int main(void) { // Double indirection box_in_a_box = cbox_BoxPoint_from(boxed_origin()); - printf("Point occupies %" PRIuMAX " bytes on the stack\n", + printf("Point occupies %" c_zu " bytes on the stack\n", sizeof(point)); - printf("Rectangle occupies %" PRIuMAX " bytes on the stack\n", + printf("Rectangle occupies %" c_zu " bytes on the stack\n", sizeof(rectangle)); // box size == pointer size - printf("Boxed point occupies %" PRIuMAX " bytes on the stack\n", + printf("Boxed point occupies %" c_zu " bytes on the stack\n", sizeof(boxed_point)); - printf("Boxed rectangle occupies %" PRIuMAX " bytes on the stack\n", + printf("Boxed rectangle occupies %" c_zu " bytes on the stack\n", sizeof(boxed_rectangle)); - printf("Boxed box occupies %" PRIuMAX " bytes on the stack\n", + printf("Boxed box occupies %" c_zu " bytes on the stack\n", sizeof(box_in_a_box)); // Copy the data contained in `boxed_point` into `unboxed_point` Point unboxed_point = *boxed_point.get; - printf("Unboxed point occupies %" PRIuMAX " bytes on the stack\n", + printf("Unboxed point occupies %" c_zu " bytes on the stack\n", sizeof(unboxed_point)); } } diff --git a/examples/complex.c b/examples/complex.c index 59683fac..5e3f53a9 100644 --- a/examples/complex.c +++ b/examples/complex.c @@ -40,7 +40,7 @@ int main() { // Put in some data in stack array stack.data[x] = 3.1415927f; - printf("stack size: %" PRIuMAX "\n", FloatStack_size(&stack)); + printf("stack size: %" c_zu "\n", FloatStack_size(&stack)); StackList list = StackList_init(); StackList_push_back(&list, stack); diff --git a/examples/csmap_erase.c b/examples/csmap_erase.c index 318d74b4..d05c32fe 100644 --- a/examples/csmap_erase.c +++ b/examples/csmap_erase.c @@ -12,7 +12,7 @@ void printmap(mymap m) { c_foreach (elem, mymap, m) printf(" [%d, %s]", elem.ref->first, cstr_str(&elem.ref->second)); - printf("\nsize() == %" PRIuMAX "\n\n", mymap_size(&m)); + printf("\nsize() == %" c_zu "\n\n", mymap_size(&m)); } int main() @@ -77,7 +77,7 @@ int main() // The 3rd member function removes elements with a given Key size_t count = mymap_erase(&m3, 2); // The 3rd member function also returns the number of elements removed - printf("The number of elements removed from m3 is: %" PRIuMAX "\n", count); + printf("The number of elements removed from m3 is: %" c_zu "\n", count); puts("After the element with a key of 2 is deleted, the map m3 is:"); printmap(m3); } diff --git a/examples/csmap_find.c b/examples/csmap_find.c index e281a431..9287a89b 100644 --- a/examples/csmap_find.c +++ b/examples/csmap_find.c @@ -18,7 +18,7 @@ void print_elem(csmap_istr_raw p) { #define using_print_collection(CX) \ void print_collection_##CX(const CX* t) { \ - printf("%" PRIuMAX " elements: ", CX##_size(t)); \ + printf("%" c_zu " elements: ", CX##_size(t)); \ \ c_foreach (p, CX, *t) { \ print_elem(CX##_value_toraw(p.ref)); \ diff --git a/examples/cstr_match.c b/examples/cstr_match.c index 614af490..a991278c 100644 --- a/examples/cstr_match.c +++ b/examples/cstr_match.c @@ -6,7 +6,7 @@ int main() { c_with (cstr ss = cstr_new("The quick brown fox jumps over the lazy dog.JPG"), cstr_drop(&ss)) { size_t pos = cstr_find_at(&ss, 0, "brown"); - printf("%" PRIuMAX " [%s]\n", pos, pos == cstr_npos ? "<NULL>" : cstr_str(&ss) + pos); + printf("%" c_zu " [%s]\n", pos, pos == cstr_npos ? "<NULL>" : cstr_str(&ss) + pos); printf("equals: %d\n", cstr_equals(&ss, "The quick brown fox jumps over the lazy dog.JPG")); printf("contains: %d\n", cstr_contains(&ss, "umps ove")); printf("starts_with: %d\n", cstr_starts_with(&ss, "The quick brown")); @@ -16,7 +16,7 @@ int main() cstr s1 = cstr_new("hell😀 w😀rl🐨"); csview ch1 = cstr_u8_chr(&s1, 7); csview ch2 = cstr_u8_chr(&s1, 10); - printf("%s\nsize: %" PRIuMAX ", %" PRIuMAX "\n", cstr_str(&s1), cstr_u8_size(&s1), cstr_size(&s1)); + printf("%s\nsize: %" c_zu ", %" c_zu "\n", cstr_str(&s1), cstr_u8_size(&s1), cstr_size(&s1)); printf("ch1: %.*s\n", c_ARGsv(ch1)); printf("ch2: %.*s\n", c_ARGsv(ch2)); } diff --git a/examples/demos.c b/examples/demos.c index d7097961..3f0125fd 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -41,14 +41,14 @@ void vectordemo1() for (size_t i = 10; i <= 100; i += 10) cvec_ix_push_back(&bignums, i * i); - printf("erase - %d: %" PRIuMAX "\n", 3, bignums.data[3]); + printf("erase - %d: %" c_zu "\n", 3, bignums.data[3]); cvec_ix_erase_n(&bignums, 3, 1); // erase index 3 cvec_ix_pop_back(&bignums); // erase the last cvec_ix_erase_n(&bignums, 0, 1); // erase the first for (size_t i = 0; i < cvec_ix_size(&bignums); ++i) { - printf("%" PRIuMAX ": %" PRIuMAX "\n", i, bignums.data[i]); + printf("%" c_zu ": %" c_zu "\n", i, bignums.data[i]); } } } @@ -175,11 +175,11 @@ void mapdemo3() cmap_str_iter it = cmap_str_find(&table, "Make"); c_foreach (i, cmap_str, table) printf("entry: %s: %s\n", cstr_str(&i.ref->first), cstr_str(&i.ref->second)); - printf("size %" PRIuMAX ": remove: Make: %s\n", cmap_str_size(&table), cstr_str(&it.ref->second)); + printf("size %" c_zu ": remove: Make: %s\n", cmap_str_size(&table), cstr_str(&it.ref->second)); //cmap_str_erase(&table, "Make"); cmap_str_erase_at(&table, it); - printf("size %" PRIuMAX "\n", cmap_str_size(&table)); + printf("size %" c_zu "\n", cmap_str_size(&table)); c_foreach (i, cmap_str, table) printf("entry: %s: %s\n", cstr_str(&i.ref->first), cstr_str(&i.ref->second)); cmap_str_drop(&table); // frees key and value cstrs, and hash table. @@ -199,7 +199,7 @@ void arraydemo1() float **arr2 = arr3.data[5]; float *arr1 = arr3.data[5][4]; - printf("arr3: %" PRIuMAX ": (%" PRIuMAX ", %" PRIuMAX ", %" PRIuMAX ") = %" PRIuMAX "\n", sizeof(arr3), + printf("arr3: %" c_zu ": (%" c_zu ", %" c_zu ", %" c_zu ") = %" c_zu "\n", sizeof(arr3), arr3.xdim, arr3.ydim, arr3.zdim, carr3_f_size(&arr3)); printf("%g\n", arr1[3]); // = 10.2 diff --git a/examples/new_queue.c b/examples/new_queue.c index eebf3493..9445e040 100644 --- a/examples/new_queue.c +++ b/examples/new_queue.c @@ -32,7 +32,7 @@ int main() { IQ_push(&Q, stc64_uniform(&rng, &dist)); // Push or pop on the queue 50 million times - printf("befor: size %" PRIuMAX ", capacity %" PRIuMAX "\n", IQ_size(&Q), IQ_capacity(&Q)); + printf("befor: size %" c_zu ", capacity %" c_zu "\n", IQ_size(&Q), IQ_capacity(&Q)); c_forloop (n) { int r = stc64_uniform(&rng, &dist); if (r & 3) @@ -40,6 +40,6 @@ int main() { else IQ_pop(&Q); } - printf("after: size %" PRIuMAX ", capacity %" PRIuMAX "\n", IQ_size(&Q), IQ_capacity(&Q)); + printf("after: size %" c_zu ", capacity %" c_zu "\n", IQ_size(&Q), IQ_capacity(&Q)); } } diff --git a/examples/prime.c b/examples/prime.c index 3f0c4f6e..851ee40b 100644 --- a/examples/prime.c +++ b/examples/prime.c @@ -25,7 +25,7 @@ cbits sieveOfEratosthenes(size_t n) int main(void) { size_t n = 1000000000; - printf("computing prime numbers up to %" PRIuMAX "\n", n); + printf("computing prime numbers up to %" c_zu "\n", n); clock_t t1 = clock(); c_with (cbits primes = sieveOfEratosthenes(n + 1), cbits_drop(&primes)) { @@ -33,7 +33,7 @@ int main(void) size_t np = cbits_count(&primes); clock_t t2 = clock(); - printf("number of primes: %" PRIuMAX ", time: %f\n", np, (t2 - t1) / (float)CLOCKS_PER_SEC); + printf("number of primes: %" c_zu ", time: %f\n", np, (t2 - t1) / (float)CLOCKS_PER_SEC); puts("Show all the primes in the range [2, 1000):"); printf("2"); c_forloop (i, 3, 1000, 2) diff --git a/examples/priority.c b/examples/priority.c index 452ed9d4..d82c889a 100644 --- a/examples/priority.c +++ b/examples/priority.c @@ -15,7 +15,7 @@ int main() { c_auto (cpque_i, heap) { // Push ten million random numbers to priority queue - printf("Push %" PRIuMAX " numbers\n", N); + printf("Push %" c_zu " numbers\n", N); c_forloop (N) cpque_i_push(&heap, stc64_uniform(&rng, &dist)); diff --git a/examples/queue.c b/examples/queue.c index 7be25367..cf75615c 100644 --- a/examples/queue.c +++ b/examples/queue.c @@ -26,6 +26,6 @@ int main() { else --n, cqueue_i_pop(&queue); } - printf("%d, %" PRIuMAX "\n", n, cqueue_i_size(&queue)); + printf("%d, %" c_zu "\n", n, cqueue_i_size(&queue)); } } diff --git a/examples/random.c b/examples/random.c index 99001a1a..638f2a9f 100644 --- a/examples/random.c +++ b/examples/random.c @@ -18,7 +18,7 @@ int main() sum += (uint32_t) stc64_rand(&rng); } diff = clock() - before; - printf("full range\t\t: %f secs, %" PRIuMAX ", avg: %f\n", (float) diff / CLOCKS_PER_SEC, N, (double) sum / N); + printf("full range\t\t: %f secs, %" c_zu ", avg: %f\n", (float) diff / CLOCKS_PER_SEC, N, (double) sum / N); stc64_uniform_t dist1 = stc64_uniform_new(0, range); rng = stc64_new(seed); @@ -28,7 +28,7 @@ int main() sum += stc64_uniform(&rng, &dist1); // unbiased } diff = clock() - before; - printf("unbiased 0-%" PRIuMAX "\t: %f secs, %" PRIuMAX ", avg: %f\n", range, (float) diff / CLOCKS_PER_SEC, N, (double) sum / N); + printf("unbiased 0-%" c_zu "\t: %f secs, %" c_zu ", avg: %f\n", range, (float) diff / CLOCKS_PER_SEC, N, (double) sum / N); sum = 0; rng = stc64_new(seed); @@ -37,6 +37,6 @@ int main() sum += stc64_rand(&rng) % (range + 1); // biased } diff = clock() - before; - printf("biased 0-%" PRIuMAX " \t: %f secs, %" PRIuMAX ", avg: %f\n", range, (float) diff / CLOCKS_PER_SEC, N, (double) sum / N); + printf("biased 0-%" c_zu " \t: %f secs, %" c_zu ", avg: %f\n", range, (float) diff / CLOCKS_PER_SEC, N, (double) sum / N); } diff --git a/examples/sso_map.c b/examples/sso_map.c index 43bcb40b..a7ee5bb5 100644 --- a/examples/sso_map.c +++ b/examples/sso_map.c @@ -10,7 +10,7 @@ int main() cmap_str_emplace(&m, "Test long ", "This is a longer string."); c_forpair (k, v, cmap_str, m) - printf("%s: '%s' Len=%" PRIuMAX ", Is long: %s\n", + printf("%s: '%s' Len=%" c_zu ", Is long: %s\n", cstr_str(_.k), cstr_str(_.v), cstr_size(_.v), cstr_is_long(_.v)?"true":"false"); } |
