Skip to content

FFI docs: state how to expose non-function symbols (or state if unsupported) #6756

Closed
@pnkfelix

Description

@pnkfelix

From reading rust.md and tutorial-ffi.md, I did not see how to expose a global variable from a library. (E.g. I've been poking at hooking into pdcurses / ncurses, and ncurses in some platforms uses global variables to expose curscr/newscr/stdscr).

As far as I can tell, one can do this via the syntax you would expect, namely:

pub extern {
    static curscr: *WINDOW;
    ....

    unsafe fn addch (_:chtype) -> c_int;
    ...
}

But we should be more up front about whether this is the official syntax, or whether I am just getting lucky here in the short-term and that one should not expect linkage to non-functions to work in the long-term.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions