Skip to content

Can't retrieve list length of native field type #33

@dpedu

Description

@dpedu

I have a struct like this:

struct Event {
    args        @0  :List(Text);
}

Which generates a struct like this:

struct Event {
    capn_ptr args;
};

Which seems wrong because if I try to get the length of the list using capn_len I cannot compile my program because capn_len tries to access a member named p and struct capn_ptr doesn't have a member named p:

In file included from bufs/main.capnp.h:4:0,
                 from event.c:3:
event.c: In function 'event_tocapn':
../deps/build/usr/local/include/capnp_c.h:182:31: error: 'capn_ptr {aka struct capn_ptr}' has no member named 'p'
 #define capn_len(list) ((list).p.type == CAPN_FAR_POINTER ? (capn_resolve(&(list).p), (list).p.len) : (list).p.len)
                               ^
event.c:173:27: note: in expansion of macro 'capn_len'
     printf("Len is %d\n", capn_len(ie->args));
                           ^~~~~~~~

...

If I use a custom defined type as the list members (such as a struct containing only a Text field) everything is fine.

From looking at other examples, it looks like this field should be a capn_data struct or one of the capn_list structs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions