Skip to content

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

New issue

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

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

Already on GitHub? # to your account

Closed
pnkfelix opened this issue May 26, 2013 · 3 comments
Closed
Labels
A-FFI Area: Foreign function interface (FFI) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@pnkfelix
Copy link
Member

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.

@emberian
Copy link
Member

emberian commented Aug 5, 2013

@alexcrichton can you clarify this?

@alexcrichton
Copy link
Member

When I was adding static mut I also "got lucky" in doing that exact syntax. At least for static mut, that's the intended syntax for interfacing with an external C library.

If this isn't documented though, I do agree that it should be documented. I'll see if I can't write up a section at least on static mut and maybe static in general inside the extern block.

@alexcrichton
Copy link
Member

Closed in 1b10391

flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 25, 2021
Factor out `clippy_utils` crate

As discussed in rust-lang/rust-clippy#6746, this PR factors out `clippy_lints::utils` as its own crate, `clippy_utils` .

This change will allow `clippy_utils` to be used in lints outside of Clippy.

There is no plan to publish this crate on `crates.io` (see rust-lang/rust-clippy#6746 (comment)). Dependent crates should obtain it from GitHub.

changelog: Factor out `clippy_utils` so it can be used by external tools (not published)
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 25, 2021
…-lints, r=flip1995

Move conf.rs back into clippy_lints

This is an alternative solution to rust-lang#6785 to fix the CI break caused by rust-lang#6756.

changelog: none
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-FFI Area: Foreign function interface (FFI) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants