Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviojs committed May 22, 2024
1 parent b7b68ef commit 05c1817
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,27 @@ pub struct Foo { .. }; // This won't be emitted by cbindgen in the header
fn bar() -> Foo { .. } // Will be emitted as `struct foo bar();`
```

### Volatile annotation

cbindgen will emit the C volatile type qualifier for types and variables that have the `volatile=true` annotation.

There is no equivalent in rust. You should use `read_volatile` and `write_volatile` to get C-like behavior.

```rust
/// cbindgen:volatile=true
type volatile_type_t = u32;

#[repr(C)]
struct S {
/// cbindgen:volatile=true
volatile_variable: u32,
}

/// cbindgen:volatile=true
#[no_mangle]
static mut volatile_global_variable: u32 = 0;
```

### Struct Annotations

* field-names=\[field1, field2, ...\] -- sets the names of all the fields in the output struct. These names will be output verbatim, and are not eligible for renaming.
Expand Down

0 comments on commit 05c1817

Please sign in to comment.