summaryrefslogtreecommitdiff
path: root/test cases/rust/20 rust and cpp/main.rs
blob: b048cac2bfb14fadef8aac61771a40808ce72d4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2023 Intel Corporation

use std::ffi::CString;
use std::os::raw::c_char;

extern "C" {
        fn lib_length(s: *const c_char) -> u64;
}

fn main() {
        let len: u64;
        unsafe {
                let c_str = CString::new("Hello, world!").unwrap();
                len = lib_length(c_str.as_ptr());
        }

        std::process::exit(if len == 13 { 0 } else { 1 })
}