-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] C bridging header "field has incomplete type" with recursive type definitions #1215
Comments
As a temporary crude hack I have added this to the end of fn reorder_recursive_types() {
let files = &[
"../ios/Runner/api_generated.h",
"../macos/Runner/api_generated.h",
];
let needle = r#"typedef struct wire_SecretRow {
struct wire_uint_8_list *id;
struct wire_SecretMeta meta;
struct wire_Secret secret;
} wire_SecretRow;
typedef struct wire_list_secret_row {
struct wire_SecretRow *ptr;
int32_t len;
} wire_list_secret_row;
typedef struct wire_UserData {
struct wire_list_secret_row *fields;
struct wire_uint_8_list *comment;
struct wire_uint_8_list *recovery_note;
} wire_UserData;
"#;
let target = r#"typedef struct wire_Secret {
int32_t tag;
union SecretKind *kind;
} wire_Secret;
"#;
for file in files {
let contents =
std::fs::read_to_string(file).expect("failed to read file");
let contents = contents.replace(needle, "");
let replacement = format!("{}\n{}", target, needle);
let contents = contents.replace(target, &replacement);
std::fs::write(file, contents).expect("failed to write file");
}
} |
Hmm I suspect it is a bug of https://github.com/mozilla/cbindgen, which FRB uses to generate .h headers. For example, maybe show api_generated.rs to cbindgen repository and tell them that the generated .h is incorrect? |
Thanks @fzyzcjy, I raised an issue here in the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
Describe the bug
Using FRB 1.75.3 codegen is successful but there are errors compiling the generated header files.
When defining recursive type definitions the order of the C struct declarations are incorrect which yields this error trying to compile on MacOS.
For now my only workaround is to re-order the definitions manually but it would be great to not have this overhead if the fix is not too difficult.
I have an
enum
where each variant has auser_data
field and in theUserData
struct is a collection of fields, so the type definitions look like this:Can anyone with knowledge of the FRB codebase indicate the difficulty to fix this problem?
Codegen logs with
RUST_LOG=debug
environment variableTo Reproduce
No response
Expected behavior
No response
Generated binding code
No response
OS
No response
Version of
flutter_rust_bridge_codegen
No response
Flutter info
No response
Version of
clang++
No response
Version of
ffigen
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: