docs

You are reading the docs for v0.1.2. Nabi 0.1.2 is no longer supported. Latest release: v0.1.3 →

#E0110: attribute on the wrong item

The attribute does not apply to this kind of item: #[export_name] on a generic or bodiless function, #[track_caller] on main, an attribute on a statement that only #[cfg] may take. Move it to an item it applies to, or remove it.

nabi
#[link_name("abs")]
fn my_abs(x: i32) -> i32 { x }
error[E0110]: `#[link_name]` cannot be attached to a function; it goes on an extern function
  --> main.nabi:1:1
   |
 1 | #[link_name("abs")]
   | ^^

Put the attribute on a function in an extern block:

nabi
extern "C" {
    #[link_name = "abs"]
    fn my_abs(x: i32) -> i32;
}
println(f"{unsafe { my_abs(-2) }}");
2

Related: E0109 malformed attribute

Found a mistake? Edit this page on GitHub. Last updated