-
Notifications
You must be signed in to change notification settings - Fork 55
Support for passing/returning Structs by value. #134
Conversation
@dcharkes Hey, I wanted to know what will happen if we pass a struct (with an incomplete definition by value), but the function was not really expecting that struct struct Struct1{
int a;
int b;
}; But instead, suppose I remove Currently, I am making sure to not generate any functions which pass/return these incomplete structs by value. Should I be doing this? |
I'm assuming C would give a static error on trying to do something with an incomplete type? If that is the case, then not generating the functions and emitting a warning/error is the right approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to get rid of lib/src/clang_library/wrapper.c
in this CL right?
We can but I think we should do that in another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a smaller PR than I would have expected. 👍
lgtm
You might want to make the next PR which removes c wrapper just to dogfood test this PR before we merge it.
I meant, that sometimes when we remove all struct members if any of the members are unsupported (like bitfield). E.g for this struct struct S{
int a;
int b:4;
} we generate this But this can't be passed by value, so I am skipping any function which uses this struct by value. |
Okay sure. |
That would result in segfaults because we would be talking about different registers/stack values. However, empty structs are undefined behavior on C, so |
* Added support for structs by value, fixed tests and example * updated version, readme, changelog * Added more tests * Added struct return by value to native test * Fix struct by value in nested typedefs
Closes dart-lang/native#540