E4156
extern “A” is unsupported in B backend.
This error happens when an FFI function written for a specific backend is
discovered during the compilation of a different backend.
Erroneous example
///|
pub extern "C" fn getchar() -> Int = "getchar"
Suggestion
You can use conditional compilation to control when the function is available.
If you want a file level conditional compilation, configure the
targets field.
moon.pkg.json
{
"targets": {
"top.mbt": ["native"]
}
}
top.mbt
///|
pub extern "C" fn getchar() -> Int = "getchar"
If you want a function level conditional compilation, add the cfg attribute.
other.mbt
///|
#cfg(target="native")
pub extern "C" fn getchar2() -> Int = "getchar"