From 3c379fbfb2b7301cd5c4f5371a9f0b96a1369b60 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 4 Mar 2022 13:18:35 +0100 Subject: Updated printf formatting to portable code. This was also to use http://winlibs.com gcc+clang with ucrt runtime-libs without warnings. --- docs/cbits_api.md | 6 +++--- docs/ccommon_api.md | 2 +- docs/cpque_api.md | 2 +- docs/cstr_api.md | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/cbits_api.md b/docs/cbits_api.md index f6077d20..1cf03c4c 100644 --- a/docs/cbits_api.md +++ b/docs/cbits_api.md @@ -89,18 +89,18 @@ cbits sieveOfEratosthenes(size_t n) int main(void) { size_t n = 100000000; - printf("computing prime numbers up to %zu\n", n); + printf("computing prime numbers up to %" PRIuMAX "\n", n); clock_t t1 = clock(); cbits primes = sieveOfEratosthenes(n + 1); size_t nprimes = cbits_count(primes); clock_t t2 = clock(); - printf("number of primes: %zu, time: %f\n", nprimes, (float)(t2 - t1)/CLOCKS_PER_SEC); + printf("number of primes: %" PRIuMAX ", time: %f\n", nprimes, (float)(t2 - t1)/CLOCKS_PER_SEC); printf(" 2"); for (size_t i = 3; i < 1000; i += 2) - if (cbits_test(primes, i>>1)) printf(" %zu", i); + if (cbits_test(primes, i>>1)) printf(" %" PRIuMAX "", i); puts(""); cbits_drop(&primes); diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index db9ef911..e7949b25 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -159,7 +159,7 @@ Declare an iterator and specify a range to iterate with a for loop. Like python' ```c c_forrange (5) printf("x"); // xxxxx -c_forrange (i, 5) printf(" %zu", i); +c_forrange (i, 5) printf(" %" PRIuMAX "", i); // 0 1 2 3 4 c_forrange (i, int, -3, 3) printf(" %d", i); // -3 -2 -1 0 1 2 diff --git a/docs/cpque_api.md b/docs/cpque_api.md index fbc1786d..97ac70f5 100644 --- a/docs/cpque_api.md +++ b/docs/cpque_api.md @@ -83,7 +83,7 @@ int main() // Extract and display the fifty smallest. c_forrange (50) { - printf("%zd ", *cpque_i_top(&heap)); + printf("%" PRIdMAX " ", *cpque_i_top(&heap)); cpque_i_pop(&heap); } } diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 0f6b2e89..4f7c689e 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -109,7 +109,7 @@ int c_strncasecmp(const char* str1, const char* str2, size_t n); int main() { cstr s0 = cstr_new("Initialization without using strlen()."); - printf("%s\nLength: %zu\n\n", s0.str, cstr_size(s0)); + printf("%s\nLength: %" PRIuMAX "\n\n", s0.str, cstr_size(s0)); cstr s1 = cstr_new("one-nine-three-seven-five."); printf("%s\n", s1.str); -- cgit v1.2.3