st3w / neo

Simulates the digital rain from "The Matrix" (CMatrix clone with 32-bit color and Unicode support)
Other
667 stars 25 forks source link

Compilation fail in macos monterey #10

Closed Reaster0 closed 2 years ago

Reaster0 commented 2 years ago

hey all! when i try to compile the tarball on macos monterey (arm) i get this undeclared identifier error, i suppose that it's just some type of variable to change for the macos compatibility

cloud.cpp:852:9: error: use of undeclared identifier 'mvinnwstr'; did you mean 'mvinnstr'?
        mvinnwstr(msgChar.line, msgChar.col, wc, 1);
        ^~~~~~~~~
        mvinnstr
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:621:28: note: 'mvinnstr' declared here
extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int);            /* generated */
                           ^
cloud.cpp:852:46: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'wchar_t [2]'
        mvinnwstr(msgChar.line, msgChar.col, wc, 1);
                                             ^~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:621:54: note: passing argument to parameter here
extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int);            /* generated */
                                                     ^
cloud.cpp:864:9: error: use of undeclared identifier 'cchar_t'; did you mean 'wchar_t'?
        cchar_t wc = {};
        ^~~~~~~
        wchar_t
cloud.cpp:865:11: error: member reference base type 'wchar_t' is not a structure or union
        wc.attr = attr;
        ~~^~~~~
cloud.cpp:866:11: error: member reference base type 'wchar_t' is not a structure or union
        wc.chars[0] = msgChar.val;
        ~~^~~~~~
cloud.cpp:870:9: error: use of undeclared identifier 'mvadd_wch'; did you mean 'mvaddch'?
        mvadd_wch(msgChar.line, msgChar.col, &wc);
        ^~~~~~~~~
        mvaddch
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:605:28: note: 'mvaddch' declared here
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);            /* generated */
                           ^
cloud.cpp:870:46: error: cannot initialize a parameter of type 'chtype' (aka 'unsigned int') with an rvalue of type 'wchar_t *'
        mvadd_wch(msgChar.line, msgChar.col, &wc);
                                             ^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:605:59: note: passing argument to parameter here
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);            /* generated */
                                                          ^

and when i try to compile from the github version i get with it this one :

droplet.cpp:144:9: error: use of undeclared identifier 'cchar_t'; did you mean 'wchar_t'?
        cchar_t wc = {};
        ^~~~~~~
        wchar_t
droplet.cpp:145:11: error: member reference base type 'wchar_t' is not a structure or union
        wc.attr = attr2;
        ~~^~~~~
droplet.cpp:146:11: error: member reference base type 'wchar_t' is not a structure or union
        wc.chars[0] = val;
        ~~^~~~~~
droplet.cpp:150:13: error: use of undeclared identifier 'mvadd_wch'; did you mean 'mvaddch'?
            mvadd_wch(line, _boundCol, &wc);
            ^~~~~~~~~
            mvaddch
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:605:28: note: 'mvaddch' declared here
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);            /* generated */
                           ^
droplet.cpp:150:40: error: cannot initialize a parameter of type 'chtype' (aka 'unsigned int') with an rvalue of type 'wchar_t *'
            mvadd_wch(line, _boundCol, &wc);
                                       ^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:605:59: note: passing argument to parameter here
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);            /* generated */
                                                          ^
droplet.cpp:153:13: error: use of undeclared identifier 'mvadd_wch'; did you mean 'mvaddch'?
            mvadd_wch(line, _boundCol, &wc);
            ^~~~~~~~~
            mvaddch
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:605:28: note: 'mvaddch' declared here
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);            /* generated */
                           ^
droplet.cpp:153:40: error: cannot initialize a parameter of type 'chtype' (aka 'unsigned int') with an rvalue of type 'wchar_t *'
            mvadd_wch(line, _boundCol, &wc);
                                       ^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/curses.h:605:59: note: passing argument to parameter here
extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);            /* generated */
                                                          ^

thanks for your work ;)

st3w commented 2 years ago

Try using Homebrew to get the latest ncurses package and then set:

export LDFLAGS="-L/opt/homebrew/opt/ncurses/lib"
export CPPFLAGS="-I/opt/homebrew/opt/ncurses/include"

It looks like the ncurses headers that come with your Mac don't have ncursesw (Unicode) support.

Reaster0 commented 2 years ago

thank you! yes it work with the alternatives path, but it's kinda weird since i have already installed ncurses with brew in the opt dir sooo mm weird

st3w commented 2 years ago

Ok, someone sent me a pull request to update the build instructions for Mac. Hopefully, that will help others.

The issue was that you had the right headers, but your compiler/linker had to be manually pointed at them. They were defaulting to old headers that don't have Unicode support. Not sure why.