Closed zapashcanon closed 1 month ago
I'm also getting:
$ owi c ./ptr.c --fail-on-assertion-only
wasm-ld-18: warning: function signature mismatch: free
>>> defined as (i32) -> i32 in lto.tmp
>>> defined as (i32) -> void in /home/zapashcanon/.config/opam/5.1.0/share/owi/binc/libc.wasm
All OK
With this code:
#include <stddef.h>
#include <owi.h>
double fabs(double x) {
return x < 0 ? -x : x;
}
double *map(double (*f)(double), double *array, size_t len) {
double *new_array = malloc(sizeof(double) * len);
for (int i = 0; i < len; i++) {
new_array[i] = f(array[i]);
}
return new_array;
}
void main(void) {
size_t len = 16;
double *array = malloc(sizeof(double) * len);
for (int i = 0; i < len; i++) {
array[i] = owi_f64();
}
double *new_array = map(fabs, array, len);
free(array);
for (int i = 0; i < len; i++) {
owi_assert(new_array[i] >= 0);
}
free(new_array);
return 0;
}
The first one is probably because the program is specifying a time
function with another type or it's not importing the function through its standard .h.
For your example use #include <stdlib.h>
instead of stddef.h
OK, and it seems that the first example is no more giving a type error so I'm closing. :)