Last active
August 29, 2015 14:13
-
-
Save jbevain/08f8138f1237715269db to your computer and use it in GitHub Desktop.
This file contains 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(lang_items)] | |
#![allow(unstable)] | |
#![allow(non_camel_case_types)] | |
extern crate libc; | |
extern crate unicode; | |
mod w32 { | |
use libc::types::os::arch::extra::{HANDLE, LPCWSTR}; | |
pub type UINT = u32; | |
pub type INT = i32; | |
pub type HWND = HANDLE; | |
pub type LPCTSTR = LPCWSTR; | |
#[link(name = "user32")] | |
extern "stdcall" { | |
pub fn MessageBoxW(hWnd: HWND, lpText: LPCTSTR, lpCaption: LPCTSTR, uType: UINT) -> INT; | |
} | |
} | |
macro_rules! L( | |
($e: expr) => ({ | |
((|&: s: &str| -> Vec<u16> { | |
let mut v: Vec<u16> = s.utf16_units().collect(); | |
v.push(0); | |
return v; | |
})($e)).as_ptr() | |
}) | |
); | |
fn main() { | |
unsafe { | |
w32::MessageBoxW(std::ptr::null_mut(), L!("Yodélilà"), L!("YO YO YO YO"), 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment