![]() So I see now why I don't get a warning, but I feel a bit insecure here. The C standard technically only requires that this type be a signed integer that is at least the size of a short some systems define it as an i16, for example. This type will almost always be i32, but may differ on some esoteric systems. Rust's documentation says: Type Definition std:: os:: raw:: c_int pub type c_int = i32 `Įquivalent to C’s signed int ( int) type. This causes i32 to be used instead of u32, but I was a bit surprised that the code then compiled, and I didn't even get any warning because an int in C is not always equal to i32. (at least as long as I don't use other types). I can fix that by adding builder = fault_macro_constant_type( When I want to use these constants in a place where a std::os::raw::c_int is expected, I get an error on mismatched types (expected i32, found u32). The other issue is that apparently integer constants (coming from header files using #define) are assumed to be of type u32 by default. I wonder if there's any good way or practice to work around that? But I assume there isn't, right? ![]() I'll have to write a wrapper for all these sort of "functions" (which are actually macros). ![]() #define example_println(x) example_print_impl((x), 1) But also "functions" implemented as macros (which are commonly found in some C header files) seem to be ignored, like: #define example_print(x) example_print_impl((x), 0) There is a ticket #753 on that in regard to macros with parameters that invoke other macros. First of all, function-like macros don't seem to be considered. ![]() I started using bindgen and the cc along with a Cargo build script to interface a C library. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |