jameysharp / corrode

C to Rust translator
GNU General Public License v2.0
2.16k stars 116 forks source link

implement struct bit-fields #75

Open meagon opened 8 years ago

meagon commented 8 years ago
("/usr/include/x86_64-linux-gnu/bits/timex.h": line 50): Corrode doesn't handle this yet:
    int : 32

while file like:

struct timex {
...
  int tai;          /* TAI offset (ro) */

  /* ??? */
  int  :32; int  :32; int  :32; int  :32;
  int  :32; int  :32; int  :32; int  :32;
  int  :32; int  :32; int  :32;
};
jameysharp commented 8 years ago

I have no idea yet what bit-fields should translate to in Rust, so if anyone has suggestions I'd love to hear them!

That said, I think we'll get a long way with #71, which should allow us to translate headers declaring types we don't know how to translate as long as those types aren't actually used in the current translation unit. This struct timex, for example, appears to be a Linux-specific type intended only for use by software like an NTP daemon, so I don't think much software is actually using it. Therefore, fixing #71 will probably get you past this error (and many like it) even if we don't implement bit-fields yet.

burdges commented 8 years ago

There is an old but open Rust RFC issue https://github.com/rust-lang/rfcs/issues/314 for discussing this, as well as a postponed proposal https://github.com/rust-lang/rfcs/pull/1449 that seemingly got close but nothing ready to roll.