Closed
Description
-
Linux documentation says it is POSIX, so I think every unix system supported by Rust has this API, but I do not know if there is an exception. What I can tell is that Linux target triples should support it. Probably
#[cfg(unix)]
should be used. -
link to the linux documentation on this function (which seems to be POSIX compliant).
use libc;
fn main() {
let name = b"foo" as *const u8 as *const i8;
let file = libc::open(name, libc::O_WRONLY);
libc::lockf(file, libc::F_TLOCK, 0);
libc::lockf(file, libc::F_ULOCK, 0);
libc::close(file);
}
- the target triple - x86_64-unknown-linux-gnu
- Try to compile the following code in the given target triple. The following error appears:
Compiling playground v0.0.1 (/playground)
error[E0425]: cannot find function `lockf` in crate `libc`
--> src/main.rs:6:11
|
6 | libc::lockf(file, libc::F_TLOCK, 0);
| ^^^^^ not found in `libc`
error[E0425]: cannot find function `lockf` in crate `libc`
--> src/main.rs:7:11
|
7 | libc::lockf(file, libc::F_ULOCK, 0);
| ^^^^^ not found in `libc`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
No labels