Skip to content

Compile error with current ncurses versions #183

Open
@drmpjz

Description

@drmpjz

Trying to compile cmatrix on openSUSE 15.5 with libncurses 6.1 fails with the following error

mzinser@sol:~/Downloads/tmp/cmatrix> make
make all-am
make[1]: Entering directory '/home/mzinser/Downloads/tmp/cmatrix'
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo -c -o cmatrix.o cmatrix.c
cmatrix.c: In function ‘resize_screen’:
cmatrix.c:287:10: error: lvalue required as left operand of assignment
COLS = win.ws_col;
^
cmatrix.c:288:11: error: lvalue required as left operand of assignment
LINES = win.ws_row;
^
cmatrix.c:292:15: error: lvalue required as left operand of assignment
LINES = 10;
^
cmatrix.c:295:14: error: lvalue required as left operand of assignment
COLS = 10;
^
cmatrix.c: In function ‘main’:
cmatrix.c:850:29: warning: implicit declaration of function ‘addwstr’; did you mean ‘addstr’? [-Wimplicit-function-declaration]
addwstr(char_array);
^~~~~~~
addstr
make[1]: *** [Makefile:436: cmatrix.o] Error 1
make[1]: Leaving directory '/home/mzinser/Downloads/tmp/cmatrix'
make: *** [Makefile:326: all] Error 2

(Note: addwstr is unrelated to this bug report, I'll open a separate issue for this.)

COLS and LINES are defined by ncurses and I gather in the past they were internal variables exposed to the outside world.
Checking the appropriate includes one sees that as of now they are actually "getter" function calls returning ints.
I did check in the source code of the latest ncurses verion (6.4), the same definitions are used there.

Obviously assigning a value does not work in this case.

The issue can be resolved by defining local variables for cols and lines in the scope of the function and using these instead.
The state of the lib is updated by the calls to resize the window in the later part of the function.

If desired I can provide the changed code either as a patch or create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions