Returning SimpleStruct with default_value attribute from abstract method results in C-side compiler error
Here's an example of such code:
[CCode (default_value = "{.member = 5}")]
[SimpleType]
public struct SimpleStruct {
uint8 member;
}
public abstract interface ExampleIface {
public abstract SimpleStruct my_method();
}
And this is troublesome method this generates in C code (#line
directives omitted, comments added by me):
SimpleStruct
example_iface_my_method (ExampleIface* self)
{
ExampleIfaceIface* _iface_;
g_return_val_if_fail (self != NULL, {.member = 5}); //< First error here
_iface_ = EXAMPLE_IFACE_GET_INTERFACE (self);
if (_iface_->my_method) {
return _iface_->my_method (self);
}
return {.member = 5}; //< Second error here
}
From my understanding, this can be solved by explicitly casting default_value
expression to relevant structure type, either always (to prevent potential issues like those from cropping up ever again) or only in those specific cases.