Array of structs of unknown content

John (J5) Palmieri johnp at
Sun May 22 15:34:16 PDT 2005

On Sun, 2005-05-22 at 13:46 -0700, Christian Hammond wrote:
> Hey guys.
> I'm trying to port Galago to D-BUS 0.30, and have ran across a problem
> that I haven't yet been able to solve. I haven't found any examples of
> this usage either.
> Basically, I need to append an array of structs. The code that handles
> this doesn't know what's in these structs. I haven't seen any code
> that appends structs to an array, so I'm wondering how I represent the
> signature. Does it actually to be:
> [signatures of members here]
> Or is there a way of just specifying that it's a struct and leaving it
> at that?
> At first I tried DBUS_TYPE_STRUCT, which D-BUS informed me was
> invalid. Then I attempted DBUS_STRUCT_BEGIN_CHAR_AS_STRING
> DBUS_STRUCT_END_CHAR_AS_STRING, but that didn't seem to work either.
> It asserts with:
> 18771: assertion failed "t != DBUS_STRUCT_END_CHAR" file
> "dbus-marshal-basic.c" line 1487 function map_type_char_to_type
> What's the correct way of doing what I want?
> Thanks,
> Christian
char sig[] = DBUS_STRUCT_BEGIN_CHAR_AS_STRING DBUS_<struct element

dbus_message_iter_open_container(&iter, TYPE_ARRAY, sig, &array_iter)

loop {

    dbus_message_iter_open_container(&array_iter, TYPE_STRUCT, NULL,

    <append struct elements here>


That should be right.  Notice that all the structs have to be the same
because all array elements must be the same.  A hack for having an array
with different elements is just to open a struct container instead of an
array.  Since you don't have to pass in the signature of the children it
should work.  Of course you would end up having to demartial it


John (J5) Palmieri <johnp at>

More information about the dbus mailing list