Skip to content

Build error by using stdscr in curses C extension module #153009

Description

@picnixz

Bug report

Bug description:

I wanted to compile Python but I got the following issue since #151748

In file included from ./Modules/_curses_panel.c:21:
./Include/py_curses.h:99:5: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
99 | PyObject *stdscr; /* the screen's standard window, or NULL */
| ^~~~~~~~
In file included from /usr/include/ncursesw/curses.h:90,
from ./Include/py_curses.h:47:
./Include/py_curses.h:99:15: error: field ‘_nc_stdscr’ declared as a function
99 | PyObject *stdscr; /* the screen's standard window, or NULL */
| ^~~~~~
make: *** [Makefile:3791: Modules/_curses_panel.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ./Modules/_cursesmodule.c:108:
./Include/py_curses.h:99:5: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
99 | PyObject *stdscr; /* the screen's standard window, or NULL */
| ^~~~~~~~
In file included from /usr/include/ncursesw/curses.h:90,
from ./Include/py_curses.h:47:
./Include/py_curses.h:99:15: error: field ‘_nc_stdscr’ declared as a function
99 | PyObject *stdscr; /* the screen's standard window, or NULL */
| ^~~~~~
./Modules/_cursesmodule.c:5128:20: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
5128 | FILE *outfp, FILE *infp, PyObject *stdscr)
| ^~~~
./Modules/_cursesmodule.c: In function ‘PyCursesScreen_New’:
./Modules/_cursesmodule.c:5138:16: error: lvalue required as left operand of assignment
5138 | so->stdscr = Py_XNewRef(stdscr);
| ^
In file included from ./Include/Python.h:80,
from ./Modules/_cursesmodule.c:96:
./Modules/_cursesmodule.c: In function ‘PyCursesScreen_clear’:
./Include/refcount.h:485:39: error: lvalue required as unary ‘&’ operand
485 | _Py_TYPEOF(op)* _tmp_op_ptr = &(op); \
| ^
./Modules/_cursesmodule.c:5200:5: note: in expansion of macro ‘Py_CLEAR’
5200 | Py_CLEAR(so->stdscr);
| ^~~~~~~~
./Modules/_cursesmodule.c: In function ‘_curses_newterm_impl’:
./Modules/_cursesmodule.c:6727:49: error: lvalue required as left operand of assignment
6727 | ((PyCursesScreenObject *)screenobj)->stdscr = Py_NewRef(win);
| ^
make: *** [Makefile:3789: Modules/_cursesmodule.o] Error 1

The problem is that my ncursesw/ncurses.h contains

#definestdscr NCURSES_PUBLIC_VAR(stdscr())

And thus using stdscr is not a valid identifier in the struct or in the parameter functions.

cc @serhiy-storchaka

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

3.16new features, bugs and security fixesbuildThe build process and cross-buildextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions