bobsquared / Mr_Bob_Chess

Chess engine in C++
GNU General Public License v3.0
9 stars 3 forks source link

Missing include <cstring> in main.cpp #4

Closed skiminki closed 1 year ago

skiminki commented 1 year ago

Main.cpp is missing an include causing a build failure on Ubuntu 23.04 as seen below:

$ make -C src -j engine
make: Entering directory '/cache/mr_bob/src/src'
g++ -O3 -o ../bob -Wall -Wextra -std=c++17 -static -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -DNDEBUG -mavx2 main.cpp bitboard.cpp magic_bitboards.cpp defs.cpp dumb7flooding.cpp movegen.cpp perft.cpp eval.cpp search.cpp uci.cpp movepick.cpp zobrist_hashing.cpp transpositionTable.cpp timeman.cpp nnue/layer.cpp nnue/KPNNUE.cpp nnue/accumulator.cpp
main.cpp: In function 'void Bench(Bitboard&)':
main.cpp:34:21: error: 'strcmp' was not declared in this scope
   34 |     for (int i = 0; strcmp(Benchmarks[i], ""); i++) {
      |                     ^~~~~~
main.cpp:27:1: note: 'strcmp' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
   26 |     #include "bench.csv"
  +++ |+#include <cstring>
   27 |         ""};
main.cpp: In function 'int main(int, char**)':
main.cpp:83:21: error: 'strcmp' was not declared in this scope
   83 |     if (argc > 1 && strcmp(argv[1], "bench") == 0) {
      |                     ^~~~~~
main.cpp:83:21: note: 'strcmp' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
make: *** [Makefile:52: engine] Error 1

And indeed, https://en.cppreference.com/w/cpp/string/byte/strcmp confirms that strcmp() needs \<cstring>, which is missing in https://github.com/bobsquared/Mr_Bob_Chess/blob/5bef2a83e5d8a27ea4c8f943e5402ffa14623cdf/src/main.cpp .