about summary refs log tree commit diff
path: root/tests/ui/abi/x86stdcall.rs
blob: c1bd35b80d266cb29c7cacedb1af6503ee3d54e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//@ run-pass
//@ only-windows
// GetLastError doesn't seem to work with stack switching

#[cfg(windows)]
mod kernel32 {
    extern "system" {
        pub fn SetLastError(err: usize);
        pub fn GetLastError() -> usize;
    }
}

#[cfg(windows)]
pub fn main() {
    unsafe {
        let expected = 1234;
        kernel32::SetLastError(expected);
        let actual = kernel32::GetLastError();
        println!("actual = {}", actual);
        assert_eq!(expected, actual);
    }
}