You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(The presence of the mut is #511, it's not the point of this issue but I'm just noting that that's a separate incorrect thing here.)
Expected Results
As it is, neither array can be used with bindgen alone. MACRO_ARRAY is not emitted and attempting to use static_const_array will result in a link error, because there is no definition, only a declaration.
// Inferred as c_int based on the types of 1 and 2staticMACRO_ARRAY:[::std::os::raw::c_int;2usize] = [1,2];static static_const_array:[::std::os::raw::c_int;2usize] = [3,4];
I figure that cases like MACRO_ARRAY are difficult in general, relating to issues like #316. But if at least the static_const_array case would work, it could be used as a simple workaround for the macro support.
Workaround
As it is, one has to write and compile some C (typically involving the cc crate) that provides a symbol to hold the array value, and in the non-macro case a way of initializing it because C can't do it at compile time. For example:
Input C Header
Bindgen Invocation
Actual Results
(The presence of the
mut
is #511, it's not the point of this issue but I'm just noting that that's a separate incorrect thing here.)Expected Results
As it is, neither array can be used with
bindgen
alone.MACRO_ARRAY
is not emitted and attempting to usestatic_const_array
will result in a link error, because there is no definition, only a declaration.I was hoping to see at least:
And ideally:
I figure that cases like
MACRO_ARRAY
are difficult in general, relating to issues like #316. But if at least thestatic_const_array
case would work, it could be used as a simple workaround for the macro support.Workaround
As it is, one has to write and compile some C (typically involving the cc crate) that provides a symbol to hold the array value, and in the non-macro case a way of initializing it because C can't do it at compile time. For example:
And then in the
bindgen
stub declare e.g.:And finally, arrange a way of calling
my_static_const_array_init
when needed.Needless to say, this is quite painful. :-) I'm open to better approaches, this is just the most straightforward thing off the top of my head.
The text was updated successfully, but these errors were encountered: