grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.5k stars 316 forks source link

Some backends (LLVM, wasm, interp, Rust...) do not know the constants from math.h #389

Open magnetophon opened 4 years ago

magnetophon commented 4 years ago

For example, when I try to compile process = ba.slidingMinN(8,8); I get:

error[E0425]: cannot find value `INFINITY` in this scope
sletz commented 4 years ago

There are still several definitions in maths.lib that do no work with all non C/C++ backends. This INFINITY specific case can probably be solved by added the value explicitly, but this problem has to be revisited more deeply.

Fr0stbyteR commented 4 years ago

Here is a list of functions from maths.lib that are not exist in wasm backend, calling them will result a calling foreign function [func_name] is not allowed in this compilation mode! error.

They can be "polyfilled" manually, as examples in wasm backend:

isnan(x) = x != x;
isinf(x) = (x == inf) | (x == -inf) with { inf = 2 * ma.INFINITY; };

note: ma.INFINITY returns singleprecision INFINITY = 3.402823466e+38; but not the actual Infinity value, while 2 * ma.INFINITY does.