Skip to content
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

cgen: force C struct types which does not implement str() to be passed as ptr #21054

Merged
merged 17 commits into from
Mar 20, 2024

Conversation

felipensp
Copy link
Member

Fix #21053

@felipensp felipensp changed the title cgen: fix to_str generation for incomplete C type cgen: force C struct types to be passed as ptr str() Mar 19, 2024
@felipensp felipensp changed the title cgen: force C struct types to be passed as ptr str() cgen: force C struct types to be passed as ptr Mar 19, 2024
@felipensp felipensp changed the title cgen: force C struct types to be passed as ptr cgen: force C struct types which does not implement str() to be passed as ptr Mar 19, 2024
@felipensp felipensp marked this pull request as ready for review March 20, 2024 11:51
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@@ -1065,6 +1076,25 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin
fn_body.writeln('\t}));')
}

// c_struct_ptr handles the C struct argument for .str() method
@[inline]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho that does not need to be inline, and it does not need to be pub too. It is only called internally in the cgen module.

@spytheman spytheman merged commit 24d1572 into vlang:master Mar 20, 2024
54 checks passed
@felipensp felipensp deleted the fix_incomplete_c_struct branch March 20, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cgen error with gcc, but not with tcc, for a program, printing an incomplete typedef C struct
2 participants