0

I'm trying to run this code in Xcode.

I get the error for the following function call mvaddwstr(row, col, shade);

Cannot initialize a parameter of type 'const char *' with an lvalue of type 'const wchar_t *'
Use of undeclared identifier 'mvaddwstr'; did you mean 'mvaddstr'?
Replace 'mvaddwstr' with 'mvaddstr'

I followed the advice here (accepted answer) and compiled the code from command line using

gcc -o 3D-Walk -D_XOPEN_SOURCE_EXTENDED 3D-Walk.cpp -lncurses

This works without any errors. How can I do the same in Xcode?

user_185051
  • 426
  • 5
  • 19
  • 1
    The answer you are trying to use has two parts: defining the symbol `_XOPEN_SOURCE_EXTENDED` and linking the library `ncurses`. Which are you having trouble with? [How to define a preprocessor symbol in Xcode](https://stackoverflow.com/questions/367368/how-to-define-a-preprocessor-symbol-in-xcode) or [Linking Libraries in Xcode](https://stackoverflow.com/questions/445815/linking-libraries-in-xcode)? – JaMiT Mar 27 '20 at 03:58
  • Thank you, the code compiles without errors now. Why `_XOPEN_SOURCE_EXTENDED` and not `D_XOPEN_SOURCE_EXTENDED`? – user_185051 Mar 27 '20 at 04:37
  • 1
    The `-` marks the beginning of a command line argument. The letters that follow it identify the type of argument. For example, `-o` means that the output file is coming next, and `-l` means the name of a library is coming next. Sometimes there is a space between the type of argument and the next thing, sometimes not (with no rule that I'm aware of other than read the documentation). A preprocessor symbol is defined by `-D` followed by the symbol to define. – JaMiT Mar 27 '20 at 06:37
  • Thank you, this is very helpful! – user_185051 Mar 27 '20 at 16:04

0 Answers0