nkarve / surge

A fast bitboard-based chess move generator in C++
MIT License
59 stars 15 forks source link

Compiling problems on Linux #19

Closed mr2anderson closed 1 year ago

mr2anderson commented 2 years ago

I have troubles with compiling this program on Linux (Debian 11 stable, gcc 10.2.1-6). I tried to compile this with different C++ versions (C++14, C++17, C++20) but I had those error messages every time:

error: the value of ‘DEBRUIJN64’ is not usable in a constant expression
note: ‘DEBRUIJN64’ was not declared ‘constexpr’

error: the value of ‘ROOK_ATTACKS’ is not usable in a constant expression
note: ‘ROOK_ATTACKS’ was not declared ‘constexpr’

error: the value of ‘BISHOP_ATTACKS’ is not usable in a constant expression
note: ‘BISHOP_ATTACKS’ was not declared ‘constexpr'

P.S. Sorry for my bad english.

rchastain commented 1 year ago

Hello! I am not a C++ expert, but here is how I solved the issue for me.

I removed the word constexpr in several places:


tables.cpp:160: /*constexpr*/ Bitboard get_rook_attacks(Square square, Bitboard occ) {
tables.cpp:226: /*constexpr*/ Bitboard get_bishop_attacks(Square square, Bitboard occ) {
tables.h:21: extern /*constexpr*/ Bitboard get_rook_attacks(Square square, Bitboard occ);
tables.h:32: extern /*constexpr*/ Bitboard get_bishop_attacks(Square square, Bitboard occ);
types.cpp:125: /*constexpr*/ Square bsf(Bitboard b) {
types.h:113: extern /*constexpr*/ Square bsf(Bitboard b);

I removed the word inline in several places:

types.cpp:86: /*inline*/ int pop_count(Bitboard x) {
types.cpp:95: /*inline*/ int sparse_pop_count(Bitboard x) {
types.cpp:118: /*inline*/ Square pop_lsb(Bitboard* b) {
types.h:107: extern /*inline*/ int pop_count(Bitboard x);
types.h:108: extern /*inline*/ int sparse_pop_count(Bitboard x);
types.h:109: extern /*inline*/ Square pop_lsb(Bitboard* b);

After that, I could compile with g++ -o test *.cpp -lstdc++.

mr2anderson commented 1 year ago

Thank you!