Closed KarelPeeters closed 8 months ago
Hi @KarelPeeters! thank you for the very well-structured detailed issue. I agree that the last solution sounds like the best fit, and I would be happy to review your PR :)
Since looking into this more and actually putting together a fix, I think the second solution is actually the better one.
russcip
already isolates users from SCIP_Result
with its own separate enum types, eg. BranchingResult
. The functions that were failing to compile earlier are exactly those that convert between those. Of course it's fine if they have to know about the underlying type, their entire purpose is hiding it from users!
I've submitted this second solution as https://github.com/scipopt/russcip/pull/115.
Problem
When trying to compile
russcip
on Windows MSVC, I get a couple of errors that are all similar to this:Cause
The underlying reason is that the
enum SCIP_Result
type is represented byunsigned int
on Linux, but byint
in Windows MSVC. Apparently this is allowed by the C++ spec:bindgen
then just exposes the underlying type asu32
ori32
to Rust, see https://github.com/rust-lang/rust-bindgen/issues/1966.In turn,
russcip
does not handle this type difference correctly, and fails to compile.Solution
I see a couple of potential solutions:
bindgen
to generate an actual Rust enum instead. This might be problematic for the reasons described in https://github.com/rust-lang/rust-bindgen/issues/758, but I don't know how this applies to SCIP specifically.russcip
, by changing all types toSCIP_Result
instead ofu32
. This is annoying because it just pushes the problem onto users, who will probably all also end up with either broken Linux or Windows builds.u32
in all the right places inrusscip
, at least for windows targets. Then everyone would be usingu32
all the time, even though it's not what the underlying SCIP library is using.I think the last solution is the easiest to implement, and also the best one. I could submit a PR for any solution if that's helpful and a decision has been made.
This might also be the only thing stopping Windows CI from working, in which case it can be turned on again! https://github.com/scipopt/russcip/blob/cc34f3d7faece624be2c1907fc3def8d0a1e86ea/.github/workflows/build_and_test.yml#L84