cty icon indicating copy to clipboard operation
cty copied to clipboard

first attempt at AVR architecture support (needed for arduino cross-compiling)

Open mutantbob opened this issue 3 years ago • 1 comments

When using bindgen to generate bindings.rs for Arduino libraries, we can not rely on the standard ctypes_prefix(). The most common replacement is cty, but cty fails to compile on the AVR platform.

error[E0432]: unresolved import `ad`
  --> /home/thoth/.cargo/registry/src/github.com-1ecc6299db9ec823/cty-0.2.2/src/lib.rs:13:9
   |
13 | pub use ad::*;
   |         ^^ maybe a missing crate `ad`?

error[E0432]: unresolved import `pwd`
  --> /home/thoth/.cargo/registry/src/github.com-1ecc6299db9ec823/cty-0.2.2/src/lib.rs:17:9
   |
17 | pub use pwd::*;
   |         ^^^ maybe a missing crate `pwd`?

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0432`.
error: could not compile `cty`

This patch attempts to correct the problem.

mutantbob avatar Feb 02 '22 21:02 mutantbob

I wrote a tiny test to make sure things line up


    check!(&mut serial, "short", unsafe{raw::size_short()}, size_of::<cty::c_short>());
    check!(&mut serial, "int", unsafe{raw::size_int()}, size_of::<cty::c_int>());
    check!(&mut serial, "long", unsafe{raw::size_long()}, size_of::<cty::c_long>());
    check!(&mut serial, "long long", unsafe{raw::size_long_long()}, size_of::<cty::c_longlong>());
    check!(&mut serial, "int*", unsafe{raw::size_int_ptr()}, size_of::<cty::intptr_t>());
size of short 2 =? 2
size of int 2 =? 2
size of long 4 =? 4
size of long long 8 =? 8
size of int* 2 =? 2

mutantbob avatar Feb 11 '22 20:02 mutantbob