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
{{ message }}
Repository navigation
Don't allow array types in extern "C" functions. #24578
A-FFIArea: Foreign function interface (FFI)A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
You cannot pass an array to or return an array from a C function.
The signature f(char x[N]) is equivalent to f(char *x) for every N in C. Therefore it is meaningless to write this in Rust, (or rather, it does not mean what a C programmer and/or FFI generation tool likely thinks it means):
A-FFIArea: Foreign function interface (FFI)A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Activity
pnkfelix commentedon Apr 18, 2015
triage: P-low
steveklabnik commentedon Jun 6, 2016
Triage: array syntax has changed, here's the correct syntax:
no warning or anything.
steveklabnik commentedon Oct 31, 2018
Triage: no change
estebank commentedon Oct 11, 2019
This would have to be implemented as a lint now due to the potential of breaking existing builds. It should be easy enough to implement.
Rollup merge of rust-lang#66305 - elichai:2019-11-array_ffi, r=eddyb