@@ -30,12 +30,6 @@ use core::mem;
30
30
use core:: ptr;
31
31
use core:: slice;
32
32
33
- // This is used when we're double-checking function signatures against windows-sys.
34
- #[ inline( always) ]
35
- fn assert_equal_types < T > ( a : T , _b : T ) -> T {
36
- a
37
- }
38
-
39
33
// This macro is used to define a `Dbghelp` structure which internally contains
40
34
// all the function pointers that we might load.
41
35
macro_rules! dbghelp {
@@ -85,14 +79,20 @@ macro_rules! dbghelp {
85
79
// either read the cached function pointer or load it and return the
86
80
// loaded value. Loads are asserted to succeed.
87
81
$( pub fn $name( & mut self ) -> Option <$name> {
82
+ // Assert that windows_sys::$name is declared to have the same
83
+ // argument types and return type as our declaration, although
84
+ // it might be either extern "C" or extern "system".
85
+ #[ cfg( windows_raw_dylib) ]
86
+ let _: unsafe extern "C" fn ( $( $argty) ,* ) -> $ret = super :: windows_sys:: $name;
87
+ #[ cfg( not( windows_raw_dylib) ) ]
88
+ let _: unsafe extern "system" fn ( $( $argty) ,* ) -> $ret = super :: windows_sys:: $name;
89
+
88
90
unsafe {
89
91
if self . $name == 0 {
90
92
let name = concat!( stringify!( $name) , "\0 " ) ;
91
93
self . $name = self . symbol( name. as_bytes( ) ) ?;
92
94
}
93
- let ret = mem:: transmute:: <usize , $name>( self . $name) ;
94
- assert_equal_types( ret, super :: windows_sys:: $name) ;
95
- Some ( ret)
95
+ Some ( mem:: transmute:: <usize , $name>( self . $name) )
96
96
}
97
97
} ) *
98
98
0 commit comments