summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-05-15 15:19:01 +0200
committerTyge Løvset <[email protected]>2021-05-15 15:19:01 +0200
commitac20f731153747ec5cbfc5566cc149485e20002a (patch)
tree008e95814cb01aeaca2ac1b336a3902e08847b30 /examples
parent560b6520ed0cb6f8faaf8309a87d4803b55a32c4 (diff)
downloadSTC-modified-ac20f731153747ec5cbfc5566cc149485e20002a.tar.gz
STC-modified-ac20f731153747ec5cbfc5566cc149485e20002a.zip
Renamed newly introduced internal c_cast() to c_make() for c++ compatability. Added usage.
Diffstat (limited to 'examples')
-rw-r--r--examples/advanced.c4
-rw-r--r--examples/random.c8
-rw-r--r--examples/stc_astar.c2
3 files changed, 7 insertions, 7 deletions
diff --git a/examples/advanced.c b/examples/advanced.c
index 73fcb470..b2dd1e57 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -28,10 +28,10 @@ static inline int vikingraw_equals(const VikingRaw* rx, const VikingRaw* ry) {
}
static inline Viking viking_fromRaw(VikingRaw raw) { // note: parameter is by value
- Viking vk = {cstr_from(raw.name), cstr_from(raw.country)}; return vk;
+ return c_make(Viking){cstr_from(raw.name), cstr_from(raw.country)};
}
static inline VikingRaw viking_toRaw(const Viking* vk) {
- VikingRaw raw = {vk->name.str, vk->country.str}; return raw;
+ return c_make(VikingRaw){vk->name.str, vk->country.str};
}
// With this in place, we use the using_cmap_keydef() macro to define {Viking -> int} hash map type:
diff --git a/examples/random.c b/examples/random.c
index 4fa1d487..32218b93 100644
--- a/examples/random.c
+++ b/examples/random.c
@@ -13,7 +13,7 @@ int main()
uint64_t sum = 0;
- stc64_normalf_t dist2 = stc64_normalf_init(R / 2.0, R / 6.0);
+ stc64_normalf_t dist2 = stc64_normalf_init((float)R / 2.0, (float)R / 6.0);
size_t N2 = 10000000;
int hist[R] = {0};
sum = 0;
@@ -28,10 +28,10 @@ int main()
printf("%3d %s\n", i, bar.str);
}
- clock_t diff, before;
+ clock_t diff, before;
sum = 0;
- before = clock();
+ before = clock();
c_forrange (N) {
sum += stc64_rand(&rng);
}
@@ -40,7 +40,7 @@ int main()
stc64_uniform_t dist1 = stc64_uniform_init(0, 1000);
sum = 0;
- before = clock();
+ before = clock();
c_forrange (N) {
sum += stc64_uniform(&rng, &dist1);
}
diff --git a/examples/stc_astar.c b/examples/stc_astar.c
index c22af8a8..90ef6e44 100644
--- a/examples/stc_astar.c
+++ b/examples/stc_astar.c
@@ -19,7 +19,7 @@ typedef struct {
MazePoint
mpnt_init(int x, int y, int width)
{
- MazePoint p = { x, y, 0, width }; return p;
+ return c_make(MazePoint){ x, y, 0, width };
}
int