Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mutantbob
Copy link

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 pushed a commit to mutantbob/rust-arduino-helpers that referenced this pull request Feb 8, 2022
@mutantbob
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant