Use init_extended (available from ncurses 6.1 and up):
If you're here today, don't worry, I'm here with a solution.
You can install ncurses library with home-brew (make sure you install the latest one which is 6.4). That saves you the burden of compiling your own, because now you can just call init_extended_color(...)
and init_extended_pair(...)
, make VERY SURE that you are using YOUR ncurses installation and not the system default, which means specifying path with -L
and name with -l
, if you won't use both you won't use both options you won't link it correctly!!!
g++ -I/opt/homebrew/Cellar/ncurses/6.4/include -I./include ./src/*.cpp -o app --std=c++20 -L/opt/homebrew/Cellar/ncurses/6.4/lib -lncurses -lform -lpanel -lmenu -o app
-lform
, -lpanel
, -lmenu
are there only because of the needs of my project: -lncurses
is the required one
Notice the fact that I specify both the -L (library path) before the -l (library name). In case you didn't know, -l looks for files in the -L path first :)
If you don't have or can't use home-brew for whatever reason, just skip the whole homebrew part.
the init_extended
functions were added in curses 6.1 and take advantage of the full 32K range of the SHORT variable. I hope it helps anyone who needs to know this today!