zenorogue / hyperrogue

A SDL roguelike in a non-euclidean world
GNU General Public License v2.0
569 stars 72 forks source link

Error compiling on Mac M1 #314

Closed battaglia01 closed 1 year ago

battaglia01 commented 2 years ago

Trying to make on a Mac M1 and am getting two different errors where it can't convert from int to std::string:

c++ -O2 -std=c++11 -DMAC -I/usr/local/include -fPIC -W -Wall -Wextra -Wsuggest-override -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-char-subscripts -Wno-unknown-warning-option -Wno-invalid-offsetof -DCAP_GLEW=0 -DCAP_PNG=0    -c hyper.cpp -o hyper.o
In file included from hyper.cpp:43:
./rulegen3.cpp:593:14: error: no matching function for call to 'genhoneycomb'
    shift(); genhoneycomb(args());
             ^~~~~~~~~~~~
./rulegen3.cpp:469:6: note: candidate function not viable: no known conversion from 'int' to 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char>>') for 1st argument
void genhoneycomb(string fname) {
     ^

./rulegen3.cpp:609:36: error: no matching function for call to 'read_file_as_string'
    shstream ins(decompress_string(read_file_as_string(args())));
                                   ^~~~~~~~~~~~~~~~~~~
./util.cpp:808:11: note: candidate function not viable: no known conversion from 'int' to 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char>>') for 1st argument
EX string read_file_as_string(string fname) {

Looking at the source, it seems there are several different functions called args(), most of which have an int return type except for the one in commandline.cpp which should return something like a const string&. What could cause this?

zenorogue commented 1 year ago

There is arg::args() which returns the current command-line argument. Various modules also have functions which parse the command-line arguments for the given modules, these functions are usually called readArgs but sometimes just args. Seems other compilers see using namespace arg; and assume that args is arg::args() while the Mac compiler assumes rulegen::args (since we are in module rulegen).

Anyway, I have noticed this problem in meantime and fixed it by explicitly specifying arg::args().