Add def.h to bindgen + solved deprecation warning
#36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Mo!
Sorry in advance for also including a deprecation-warning fix in this PR, figured I would tackle that one as well.
The reason why I need this is because of
SCIP_INVALID. (See scipopt/russcip#269)This constant is defined as a C-macro over here; https://scipopt.org/doc/html/def_8h_source.php#l00178. It would be nice if we had access to this macro in Rust as well. By letting
bindgengenerate these constants, we do not need to manually define everything ourselves. Therefore, I added 'def.h' tobindgen.There was one problem though,
bindgenhas a hard time when dealing with type-casts in macros. Therefore it skipped generating bindings forSCIP_INVALID. The solution for this was defining a callback by implementing this trait. This callback looks for a pattern like: '( KEYWORD )', where I believe the KEYWORD to be a clang-keyword. I did not dare to dive further in the clang-rabbithole, but it seemed to work for standard C-types (double) and not for other types likeSCIP_Real. Which is precisely what I think we should want.As an extra safety I made sure that the macros we want to target should be added to the
DeriveCastedConstantstruct. I think thatbindgenmust have a good reason why it ignores type-casted macros, so I think it is best to not let this callback blindly noscope every single type-casted macro that crosses its path!I tested this in my local version of
russcipand was able to accessffi::SCIP_INVALID. 🎉