Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Compile error with current ncurses versions #183

Open
drmpjz opened this issue Feb 29, 2024 · 1 comment
Open

Compile error with current ncurses versions #183

drmpjz opened this issue Feb 29, 2024 · 1 comment
Labels

Comments

@drmpjz
Copy link

drmpjz commented Feb 29, 2024

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.

@drmpjz drmpjz added the Bug label Feb 29, 2024
@drmpjz
Copy link
Author

drmpjz commented Mar 7, 2024

Created PR #184 for this.

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

No branches or pull requests

1 participant