summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-10-21 09:26:13 +0200
committerTyge Løvset <[email protected]>2022-10-21 09:26:13 +0200
commit2cefae32252f3051f75f44f4718a62a1210bd3a7 (patch)
treebe09d9f91e918ad36a21e5919200e8343b3e0884 /examples
parent650f6218c1b2afce696b2dd7e98c76dcdeafce24 (diff)
downloadSTC-modified-2cefae32252f3051f75f44f4718a62a1210bd3a7.tar.gz
STC-modified-2cefae32252f3051f75f44f4718a62a1210bd3a7.zip
Fixed wrong formatting of 64bit values various places.
Finialized cbox/carc issues.
Diffstat (limited to 'examples')
-rw-r--r--examples/birthday.c7
-rw-r--r--examples/city.c1
-rw-r--r--examples/demos.c4
-rw-r--r--examples/music_arc.c1
-rw-r--r--examples/random.c11
5 files changed, 15 insertions, 9 deletions
diff --git a/examples/birthday.c b/examples/birthday.c
index 443394b2..48b8ceaa 100644
--- a/examples/birthday.c
+++ b/examples/birthday.c
@@ -24,7 +24,8 @@ static void test_repeats(void)
c_forrange (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 %" c_zu " (%d) at 2^%d\n", k, v, (int) log2((double) i));
+ if (v > 1) printf("repeated value %" PRIu64 " (%d) at 2^%d\n",
+ k, v, (int) log2((double) i));
}
}
}
@@ -52,7 +53,9 @@ void test_distribution(void)
sum /= map.size;
c_foreach (i, cmap_x, map) {
- printf("%4u: %" c_zu " - %" c_zu ": %11.8f\n", i.ref->first, i.ref->second, sum, (1 - (double) i.ref->second / sum));
+ printf("%4" PRIu32 ": %" PRIu64 " - %" PRIu64 ": %11.8f\n",
+ i.ref->first, i.ref->second, sum,
+ (1 - (double)i.ref->second / sum));
}
}
}
diff --git a/examples/city.c b/examples/city.c
index 0bae631a..891e08f8 100644
--- a/examples/city.c
+++ b/examples/city.c
@@ -14,7 +14,6 @@ void City_drop(City* c);
#define i_type CityArc
#define i_val_class City
-
#include <stc/cbox.h>
//#include <stc/carc.h> // try instead of cbox.h
diff --git a/examples/demos.c b/examples/demos.c
index d15e5c6e..457e5f4d 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(&bignums, i * i);
- printf("erase - %d: %" c_zu "\n", 3, bignums.data[3]);
+ printf("erase - %d: %" PRIu64 "\n", 3, bignums.data[3]);
cvec_ix_erase_n(&bignums, 3, 1); // erase index 3
cvec_ix_pop(&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("%" c_zu ": %" c_zu "\n", i, bignums.data[i]);
+ printf("%" c_zu ": %" PRIu64 "\n", i, bignums.data[i]);
}
}
}
diff --git a/examples/music_arc.c b/examples/music_arc.c
index d4b9ab14..0fb0dd70 100644
--- a/examples/music_arc.c
+++ b/examples/music_arc.c
@@ -22,6 +22,7 @@ void Song_drop(Song* s) {
// Define the reference counted type
#define i_type SongArc
#define i_val_class Song
+#define i_opt c_no_hash
#include <stc/carc.h>
// ... and a vector of it
diff --git a/examples/random.c b/examples/random.c
index 38ef2e39..6ebda57e 100644
--- a/examples/random.c
+++ b/examples/random.c
@@ -15,10 +15,11 @@ int main()
sum = 0;
before = clock();
c_forrange (N) {
- sum += (uint32_t) stc64_rand(&rng);
+ sum += (uint32_t)stc64_rand(&rng);
}
diff = clock() - before;
- printf("full range\t\t: %f secs, %" c_zu ", 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 +29,8 @@ int main()
sum += stc64_uniform(&rng, &dist1); // unbiased
}
diff = clock() - before;
- printf("unbiased 0-%" c_zu "\t: %f secs, %" c_zu ", avg: %f\n", range, (float) diff / CLOCKS_PER_SEC, N, (double) sum / N);
+ printf("unbiased 0-%" PRIu64 "\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 +39,7 @@ int main()
sum += stc64_rand(&rng) % (range + 1); // biased
}
diff = clock() - before;
- printf("biased 0-%" c_zu " \t: %f secs, %" c_zu ", avg: %f\n", range, (float) diff / CLOCKS_PER_SEC, N, (double) sum / N);
+ printf("biased 0-%" PRIu64 " \t: %f secs, %" c_zu ", avg: %f\n",
+ range, (float)diff / CLOCKS_PER_SEC, N, (double)sum / N);
}