Created
December 13, 2016 21:22
-
-
Save timglabisch/479d67a8dd9ce6d2eaf5f7227a5dd08b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(libc)] | |
extern crate libc; | |
use libc::{c_void, c_int, c_char, c_uchar, c_uint}; | |
use std::ffi::{CString,}; | |
use std::ptr; | |
pub fn main() { | |
struct foo { | |
fname: *const c_char | |
} | |
static variable: &'static [foo] = &[ | |
foo { | |
fname: "some literal".as_ptr() as *const c_char, | |
}, | |
foo { | |
fname: ptr::null(), | |
} | |
]; | |
variable as *const foo; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cargo run | |
Compiling static-lifetime v0.1.0 (file:///Users/tim/proj_/rust/static-lifetime) | |
error: casting `&'static [main::foo]` as `*const main::foo` is invalid | |
--> src/main.rs:23:5 | |
| | |
23 | variable as *const foo; | |
| ^^^^^^^^^^^^^^^^^^^^^^ | |
error: aborting due to previous error | |
error: Could not compile `static-lifetime`. | |
To learn more, run the command again with --verbose. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment