Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

ncurses::stdscr will require unsafe block #115

Closed
gyscos opened this issue Sep 20, 2016 · 2 comments
Closed

ncurses::stdscr will require unsafe block #115

gyscos opened this issue Sep 20, 2016 · 2 comments

Comments

@gyscos
Copy link
Collaborator

gyscos commented Sep 20, 2016

Using latest Rust nightly, accessing static extern require unsafe (see rust-lang/rust#35112):

The examples now produce this error:

% rustc --version
rustc 1.13.0-nightly (55bf6a4f8 2016-09-18)
% cargo build --example ex_2
   Compiling ncurses v5.82.0 (file:///home/gyscos/fetched/ncurses-rs)
warning: use of extern static requires unsafe function or block (error E0133), #[warn(safe_extern_statics)] on by default
  --> examples/ex_2.rs:23:10
   |
23 |   keypad(stdscr, true);
   |          ^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue 36247 <https://github.com/rust-lang/rust/issues/35112>

    Finished debug [unoptimized + debuginfo] target(s) in 0.21 secs
@jeaye
Copy link
Owner

jeaye commented Sep 23, 2016

Thanks for the report! Do you feel comfortable sending in a PR for this?

@gyscos
Copy link
Collaborator Author

gyscos commented Sep 24, 2016

#116 moves these variables to an internal module, and exposes safe wrapper functions instead. Examples have been updated.

NOTE: since it changes those from variable to functions, it probably breaks most code that use those.
I'm not sure how to solve this issue without going through a function though.
Also, a "useless unsafe block" warning may appear on older compilers (including the current stable branch).

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

No branches or pull requests

2 participants