Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dpedu opened this issue Mar 28, 2019 · 0 comments
Open

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

dpedu opened this issue Mar 28, 2019 · 0 comments

Comments

@dpedu
Copy link

dpedu commented Mar 28, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant