zenorogue / hyperrogue

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

Various small compiler-warning fixes #308

Closed Quuxplusone closed 2 years ago

Quuxplusone commented 2 years ago

I haven't yet figured out where this warning is coming from:

In file included from rogueviz/rogueviz-all.cpp:21,
                 from hyper.cpp:128:
rogueviz/qtm.cpp:217:15: error: embedding a directive within macro arguments is not portable [-Werror]
  217 |               #if CAP_RAY
      |               ^

Here are the warnings I still see, after this patch series, when I build locally with top-of-tree Clang:

clang++ -O2 -std=c++11 -Wembedded-directive -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:47:
./crystal.cpp:856:7: warning: variable 'steps' set but not used [-Wunused-but-set-variable]
  int steps = 0;
      ^
In file included from hyper.cpp:82:
In file included from ./3d-models.cpp:9:
./earcut.hpp:283:9: warning: variable 'iterations' set but not used [-Wunused-but-set-variable]
    int iterations = 0;
        ^
In file included from hyper.cpp:82:
./3d-models.cpp:530:7: warning: variable 'it' set but not used [-Wunused-but-set-variable]
  int it = 0;
      ^
./3d-models.cpp:745:16: warning: variable 'qtyall' set but not used [-Wunused-but-set-variable]
  int qty = 0, qtyall = 0;
               ^
In file included from hyper.cpp:85:
./drawing.cpp:1417:11: warning: variable 'ia' set but not used [-Wunused-but-set-variable]
      int ia = 0, ib = 0, ic = 0;
          ^
./drawing.cpp:1417:19: warning: variable 'ib' set but not used [-Wunused-but-set-variable]
      int ia = 0, ib = 0, ic = 0;
                  ^
./drawing.cpp:1417:27: warning: variable 'ic' set but not used [-Wunused-but-set-variable]
      int ia = 0, ib = 0, ic = 0;
                          ^
In file included from hyper.cpp:117:
./barriers.cpp:980:7: warning: variable 'a0' set but not used [-Wunused-but-set-variable]
  int a0 = 0;
      ^
In file included from hyper.cpp:118:
./surface.cpp:194:10: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
  return flag_clamp_min(coord, minv) & flag_clamp_max(coord, maxv);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     &&
./surface.cpp:194:10: note: cast one or both operands to int to silence this warning
./surface.cpp:212:14: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
      return flag_clamp_min(x, 0) & flag_clamp_sym(y, M_PI);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                  &&
./surface.cpp:212:14: note: cast one or both operands to int to silence this warning
./surface.cpp:215:14: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
      return flag_clamp(x, 0, M_PI) & flag_clamp(y, 0, 2*M_PI);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    &&
./surface.cpp:215:14: note: cast one or both operands to int to silence this warning
./surface.cpp:218:14: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
      return flag_clamp_sym(x, M_PI) & flag_clamp_sym(y, hyperlike_bound());
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     &&
./surface.cpp:218:14: note: cast one or both operands to int to silence this warning