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

C ABI: Add C support for passing structs of floats to an extern function #5461

Merged
merged 1 commit into from May 29, 2020

Conversation

FireFox317
Copy link
Contributor

@FireFox317 FireFox317 commented May 28, 2020

Currently this does not handle returning these structs yet, because I'm not sure where in the Zig codebase this is handled.

Also while working on this, I found out that the code that detects which C ABI Class should be used is quite outdated (from 2014). Version 1.0 can be found here (Yes, official documents on a github wiki page lol).

Also, this looks like a bug. Its iterating but then only looking at the first field, same issue for the union case. Basically this code needs a refactor.

zig/src/analyze.cpp

Lines 7978 to 7979 in 2ae9e06

for (uint32_t i = 0; i < ty->data.structure.src_field_count; i += 1) {
X64CABIClass field_class = type_c_abi_x86_64_class(g, ty->data.structure.fields[0]->type_entry);

Related: #1481

Currently this does not handle returning these structs yet.

Related: ziglang#1481
@andrewrk andrewrk merged commit 6e89692 into ziglang:master May 29, 2020
@andrewrk
Copy link
Member

Nice work!

@andrewrk
Copy link
Member

Did this solve #3211 ?

@daurnimator
Copy link
Collaborator

Did this solve #3211 ?

No, that issue is about returning structs; this PR adds passing structs (as arguments).

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.

None yet

3 participants