For some reason, -std=c99 is keeping gcc from seeing the declaration of function wborder_set() (which lives in <curses.h>
)
#include <curses.h>
#include <locale.h>
int main(int argc, char* argv[]){
initscr(); // start ncurses
cbreak(); // don't wait for lf to getch
noecho(); // don't copy entered characters
nonl(); // use /r/l
clear(); // clear the screen!
setlocale(LC_CTYPE, "");
int ySize, xSize;
getmaxyx(stdscr, ySize, xSize);
WINDOW *upperWin = newwin(ySize, xSize, 0, 0);
// magic utf encodings for window border
wborder_set( upperWin, "\u1234", "\u1234", "\u1234", "\u1234",
"\u1234", "\u1234", "\u1234", "\u1234" );
wrefresh(upperWin);
getch();
return 0;
}
Compiling with gcc test.c -lncursesw -o cursestest
works fine! If, however, I compile with
gcc test.c -std=c99 -lncursesw -o cursestest
it replies,
cursescurses.c: In function ‘main’:
cursescurses.c:18:7: warning: implicit declaration of function ‘wborder_set’ [-Wimplicit-function-declaration]
wborder_set( upperWin, "\u1234", "\u1234", "\u1234", "\u1234",
which leads me to believe that I can't trust that it is properly linking wborder_set.
Why would this happen?
It turns out the problem was that I had included the wrong version of
<curses.h>
. The functionwborder_set
implements unicode and needed the unicode/wide char extension of the ncurses library, which I included with#include <ncursesw/curses.h>
. With this substitution, the program compiled as expected.