Skip to content

Instantly share code, notes, and snippets.

@timglabisch
Created December 13, 2016 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timglabisch/479d67a8dd9ce6d2eaf5f7227a5dd08b to your computer and use it in GitHub Desktop.
Save timglabisch/479d67a8dd9ce6d2eaf5f7227a5dd08b to your computer and use it in GitHub Desktop.
#![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;
}
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