You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
boolnames is a global array-of-char* that curses provides. (It's actually declared as extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];.)
The C version spits out the entire array, starting with:
0x600aa0 0x7f6eb0dcd831 b bw
0x600aa8 0x7f6eb0dd5703 a am
0x600ab0 0x7f6eb0dd6199 x xsb
The Rust version spits out:
7f7a9ec58831 7378006278007762
...and then segfaults trying to evaluate **p. Cursory inspection reveals that the value given for *p is actually the string bw\0xb\0xs. Somehow the first level of indirection is disappearing.
The text was updated successfully, but these errors were encountered:
There is no two levels of indirection since it's an array and not a double pointer in curses. In your C code, the implicit array-to-pointer conversion does what you expect, but straight-up telling rustc that the symbol boolnames refers to a double pointer instead of a series of single pointers can't go well.
I don't know how to properly deal with unknown-but-static-length arrays in rust, but if you change the extern declaration to const boolnames: [*c_char * 1]; and then say let mut p: **c_char = ptr::to_unsafe_ptr(&boolnames[0]);, it'll print a pile of stuff and not segfault.
0.4.
boolnames
is a global array-of-char*
that curses provides. (It's actually declared asextern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];
.)https://gist.github.com/3995350
The C version spits out the entire array, starting with:
The Rust version spits out:
...and then segfaults trying to evaluate
**p
. Cursory inspection reveals that the value given for*p
is actually the stringbw\0xb\0xs
. Somehow the first level of indirection is disappearing.The text was updated successfully, but these errors were encountered: