<div dir="ltr">Hi, thanks! You are correct about the signature, I was trying various things and pasted in some half complete code, sorry. After changing to pass the fields of the struct as individual parameters it does work correctly. <div><br></div><div>I guess I would prefer to pass the struct so that you can share a single definition of the struct with both the client and service so as to avoid possible errors where you pass the fields in the wrong order. Also if you have a large struct it's a bit inconvenient to spell out every field on both ends. </div><div><br></div><div>I thought it would be possible for sd-bus to marshall my C struct into a D-bus struct. Perhaps that is not possible? </div><div><br></div><div>Niall</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 23 Aug 2018 at 18:35, Simon McVittie <<a href="mailto:smcv@collabora.com">smcv@collabora.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, 23 Aug 2018 at 16:52:38 +0200, Niall Murphy wrote:<br>
> struct pack {<br>
>     int x;<br>
>     int y;<br>
> };<br>
...<br>
>     return sd_bus_reply_method_return(m, "(xx)", s);<br>
<br>
Is there a reason why you're returning a struct/tuple? D-Bus methods<br>
can return as many things as you want[1], unlike C functions, so a more<br>
conventional return type would be "xx" instead of "(xx)".<br>
<br>
You also have a mismatch between your integer types: "x" is a 64-bit signed<br>
integer (mnemonic: the 64-bit signed and unsigned types are "x" and "t",<br>
which are the first letters of "sixty" that weren't already used for<br>
something more important) so they'll expect an int64_t. The type<br>
signatures for 32-bit integers are "i" and "u", depending on signedness.<br>
There is no correct type signature for types like int/long/long long<br>
whose size can vary between platform: integers in D-Bus messages are<br>
always fixed-size.<br>
<br>
Finally, I think the message-building API expects struct members as<br>
individual arguments, like<br>
<br>
    sd_bus_reply_method_return(m, "xx", (int64_t) s->x, (int64_t) s->y);<br>
<br>
although I could be wrong about that.<br>
<br>
    smcv<br>
<br>
[1] up to arbitrary message size limits measured in megabytes<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>