Bindgen natively only considers .hpp to be C++ headers, but Meson considers some additional extensions including .hh and .hxx to be C++.pull/12263/head
parent
2c7833b1c9
commit
6a8330af59
6 changed files with 73 additions and 9 deletions
@ -0,0 +1,6 @@ |
||||
## Bindgen will now use Meson's hueristic for what is a C++ header |
||||
|
||||
Bindgen natively assumes that a file with the extension `.cpp` is a C++ header, |
||||
but that everything else is a C header. Meson has a whole list of extensions it |
||||
considers to be C++, and now will automatically look for those extensions and |
||||
set bindgen to treat those as C++ |
@ -0,0 +1,19 @@ |
||||
// SPDX-license-identifer: Apache-2.0
|
||||
// Copyright © 2023 Intel Corporation
|
||||
|
||||
#![allow(non_upper_case_globals)] |
||||
#![allow(non_camel_case_types)] |
||||
#![allow(non_snake_case)] |
||||
|
||||
include!("generated-cpp.rs"); |
||||
|
||||
fn main() { |
||||
let mut instance = std::mem::MaybeUninit::<MyClass>::uninit(); |
||||
let val: i32; |
||||
unsafe { |
||||
MyClass_MyClass(instance.as_mut_ptr()); |
||||
val = instance.assume_init_mut().method(); |
||||
} |
||||
let success = val == 7; |
||||
std::process::exit(!success as i32); |
||||
} |
@ -0,0 +1,9 @@ |
||||
#pragma once |
||||
|
||||
class MyClass { |
||||
public: |
||||
MyClass(); |
||||
int method() const; |
||||
private: |
||||
int val; |
||||
}; |
@ -0,0 +1,7 @@ |
||||
#include "header.hpp" |
||||
|
||||
MyClass::MyClass() : val{7} {}; |
||||
|
||||
int MyClass::method() const { |
||||
return val; |
||||
} |
Loading…
Reference in new issue