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

'tdb_cursor_next' magic #120

Open
19h opened this issue Jan 26, 2017 · 1 comment
Open

'tdb_cursor_next' magic #120

19h opened this issue Jan 26, 2017 · 1 comment

Comments

@19h
Copy link

19h commented Jan 26, 2017

Hey,

I'm currently updating the TrailDB rust binding and noticed a strange behaviour where the binding generator isn't finding tdb_cursor_next.

Then I realized it's exported in a non-standard way:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
__attribute__((visibility("default"))) inline const tdb_event *tdb_cursor_next(tdb_cursor *cursor)
{
    if (cursor->num_events_left > 0 || _tdb_cursor_next_batch(cursor)){
        const tdb_event *e = (const tdb_event*)cursor->next_event;
        cursor->next_event += sizeof(tdb_event) +
                              e->num_items * sizeof(tdb_item);
        --cursor->num_events_left;
        return e;
    }else
        return NULL;
}
#pragma GCC diagnostic pop

This is a huge problem for Clang because the GCC attributes effectively make the method invisible for the outside world. In the binding, I manually removed the attributes in order to have it compile using Clang.

-- Kenan

🚀

@Noeda
Copy link
Contributor

Noeda commented Apr 28, 2017

IMO there should be an equivalent function in traildb.h that is otherwise exactly the same as tdb_cursor_next but is friendly to bindings. It's not just Clang world but also different language bindings would have slightly easier time binding to C APIs when they can't directly bind to inlined C functions. @tuulos

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

No branches or pull requests

3 participants