so I downloaded this chess engine: http://www.ascotti.org/programming/chess/chess.htm
and I tried to compile & run it with eclipse...but then it displayed a whole bunch of error...
among them there's a lot of 'X was not declared in this scope' errors in multiple files including bitboard.h, hash.h, and pawnhash.h....
what does that error mean and how would you resolve these errors from these code?
also there's a lot of Uint64 has not been declared errors such as in bitboard.h...
again why is that the case, and how would you resolve it?
thx in advance
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\system.o ..\src\system.cxx
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\position_evaluate_pawn.o ..\src\position_evaluate_pawn.cxx
In file included from ..\src\board.h:25,
from ..\src\position_evaluate_pawn.cxx:23:
..\src\bitboard.h:35: error: `bitCount' declared as an `inline' variable
..\src\bitboard.h:35: error: `Uint64' was not declared in this scope
..\src\bitboard.h:36: error: expected `,' or `;' before '{' token
..\src\bitboard.h:64: error: expected `)' before "lo"
..\src\bitboard.h:68: error: expected `)' before "n"
..\src\bitboard.h:85: error: `Uint64' has not been declared
..\src\bitboard.h:85: error: ISO C++ forbids declaration of `bb' with no type
..\src\bitboard.h:103: error: `Uint64' has not been declared
..\src\bitboard.h:103: error: ISO C++ forbids declaration of `bb' with no type
..\src\bitboard.h:107: error: `Uint64' has not been declared
..\src\bitboard.h:107: error: ISO C++ forbids declaration of `bb' with no type
..\src\bitboard.h:111: error: `Uint64' has not been declared
..\src\bitboard.h:111: error: ISO C++ forbids declaration of `bb' with no type
..\src\bitboard.h:223: error: `Uint64' does not name a type
..\src\bitboard.h: In copy constructor `BitBoard::BitBoard(const BitBoard&)':
..\src\bitboard.h:73: error: `data' was not declared in this scope
..\src\bitboard.h:73: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:73: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator=(const BitBoard&)':
..\src\bitboard.h:82: error: `data' was not declared in this scope
..\src\bitboard.h:82: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:82: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator=(int)':
..\src\bitboard.h:86: error: `data' was not declared in this scope
..\src\bitboard.h:86: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator&=(const BitBoard&)':
..\src\bitboard.h:91: error: `data' was not declared in this scope
..\src\bitboard.h:91: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:91: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator|=(const BitBoard&)':
..\src\bitboard.h:95: error: `data' was not declared in this scope
..\src\bitboard.h:95: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:95: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator^=(const BitBoard&)':
..\src\bitboard.h:99: error: `data' was not declared in this scope
..\src\bitboard.h:99: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:99: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator&=(int)':
..\src\bitboard.h:104: error: `data' was not declared in this scope
..\src\bitboard.h:104: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator|=(int)':
..\src\bitboard.h:108: error: `data' was not declared in this scope
..\src\bitboard.h:108: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::operator^=(int)':
..\src\bitboard.h:112: error: `data' was not declared in this scope
..\src\bitboard.h:112: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard BitBoard::operator<<(int) const':
..\src\bitboard.h:116: error: `data' was not declared in this scope
..\src\bitboard.h:116: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard BitBoard::operator>>(int) const':
..\src\bitboard.h:120: error: `data' was not declared in this scope
..\src\bitboard.h:120: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard BitBoard::operator~() const':
..\src\bitboard.h:125: error: `data' was not declared in this scope
..\src\bitboard.h:125: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard BitBoard::operator&(const BitBoard&) const':
..\src\bitboard.h:129: error: `data' was not declared in this scope
..\src\bitboard.h:129: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:129: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard BitBoard::operator|(const BitBoard&) const':
..\src\bitboard.h:133: error: `data' was not declared in this scope
..\src\bitboard.h:133: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:133: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard BitBoard::operator^(const BitBoard&) const':
..\src\bitboard.h:137: error: `data' was not declared in this scope
..\src\bitboard.h:137: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:137: warning: unused variable 'data'
..\src\bitboard.h: In member function `int BitBoard::operator<(const BitBoard&) const':
..\src\bitboard.h:141: error: `data' was not declared in this scope
..\src\bitboard.h:141: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:141: warning: unused variable 'data'
..\src\bitboard.h: In member function `int BitBoard::operator>(const BitBoard&) const':
..\src\bitboard.h:145: error: `data' was not declared in this scope
..\src\bitboard.h:145: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:145: warning: unused variable 'data'
..\src\bitboard.h: In member function `int BitBoard::operator==(const BitBoard&) const':
..\src\bitboard.h:150: error: `data' was not declared in this scope
..\src\bitboard.h:150: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:150: warning: unused variable 'data'
..\src\bitboard.h: In member function `int BitBoard::operator!=(const BitBoard&) const':
..\src\bitboard.h:154: error: `data' was not declared in this scope
..\src\bitboard.h:154: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:154: warning: unused variable 'data'
..\src\bitboard.h: In member function `BitBoard::operator int() const':
..\src\bitboard.h:159: error: `data' was not declared in this scope
..\src\bitboard.h:159: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::setBit(unsigned int)':
..\src\bitboard.h:164: error: `data' was not declared in this scope
..\src\bitboard.h:164: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:164: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::clrBit(unsigned int)':
..\src\bitboard.h:168: error: `data' was not declared in this scope
..\src\bitboard.h:168: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:168: warning: unused variable 'data'
..\src\bitboard.h: In member function `int BitBoard::getBit(unsigned int) const':
..\src\bitboard.h:173: error: `data' was not declared in this scope
..\src\bitboard.h:173: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:173: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::clear()':
..\src\bitboard.h:178: error: `data' was not declared in this scope
..\src\bitboard.h:178: warning: unused variable 'data'
..\src\bitboard.h: In member function `void BitBoard::negate()':
..\src\bitboard.h:182: error: `data' was not declared in this scope
..\src\bitboard.h: In member function `void BitBoard::andNot(const BitBoard&)':
..\src\bitboard.h:186: error: `data' was not declared in this scope
..\src\bitboard.h:186: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:186: warning: unused variable 'data'
..\src\bitboard.h: In member function `unsigned int BitBoard::getRank(int) const':
..\src\bitboard.h:191: error: `data' was not declared in this scope
..\src\bitboard.h:191: warning: unused variable 'data'
..\src\bitboard.h: In member function `int BitBoard::isEmpty() const':
..\src\bitboard.h:196: error: `data' was not declared in this scope
..\src\bitboard.h:196: warning: unused variable 'data'
..\src\bitboard.h: In member function `unsigned int BitBoard::toByte() const':
..\src\bitboard.h:201: error: `data' was not declared in this scope
..\src\bitboard.h:201: warning: unused variable 'data'
..\src\bitboard.h: In member function `unsigned int BitBoard::toUnsigned() const':
..\src\bitboard.h:206: error: `data' was not declared in this scope
..\src\bitboard.h:206: warning: unused variable 'data'
..\src\bitboard.h: In member function `bool BitBoard::isZero() const':
..\src\bitboard.h:213: error: `data' was not declared in this scope
..\src\bitboard.h:213: warning: unused variable 'data'
..\src\bitboard.h: In member function `bool BitBoard::isNotZero() const':
..\src\bitboard.h:217: error: `data' was not declared in this scope
..\src\bitboard.h:217: warning: unused variable 'data'
..\src\bitboard.h: In function `unsigned int bitSearch(BitBoard)':
..\src\bitboard.h:231: error: `Uint64' was not declared in this scope
..\src\bitboard.h:231: error: expected `;' before "b"
..\src\bitboard.h:232: error: `b' was not declared in this scope
..\src\bitboard.h:231: warning: unused variable 'Uint64'
..\src\bitboard.h: In function `unsigned int bitSearchAndReset(BitBoard&)':
..\src\bitboard.h:238: error: `Uint64' was not declared in this scope
..\src\bitboard.h:238: error: expected `;' before "b"
..\src\bitboard.h:239: error: 'class BitBoard' has no member named 'data'
..\src\bitboard.h:239: error: 'class BitBoard' has no member named 'data'
..\src\bitboard.h:239: error: 'class BitBoard' has no member named 'data'
..\src\bitboard.h:240: error: `b' was not declared in this scope
..\src\bitboard.h:238: warning: unused variable 'Uint64'
..\src\bitboard.h: In function `int bitScanForward(BitBoard)':
..\src\bitboard.h:246: error: 'class BitBoard' has no member named 'data'
..\src\bitboard.h: In function `int bitScanAndResetForward(BitBoard&)':
..\src\bitboard.h:251: error: 'class BitBoard' has no member named 'data'
..\src\bitboard.h: In function `int bitCount(const BitBoard&)':
..\src\bitboard.h:255: error: `int bitCount(const BitBoard&)' redeclared as different kind of symbol
..\src\bitboard.h:35: error: previous declaration of `int bitCount'
..\src\bitboard.h:35: error: previous non-function declaration `int bitCount'
..\src\bitboard.h:255: error: conflicts with function declaration `int bitCount(const BitBoard&)'
..\src\bitboard.h:256: error: 'const class BitBoard' has no member named 'data'
..\src\bitboard.h:256: error: `bitCount' cannot be used as a function
..\src\bitboard.h: In member function `int BitBoard::bitScanForward() const':
..\src\bitboard.h:260: error: `data' was not declared in this scope
..\src\bitboard.h:260: warning: unused variable 'data'
In file included from ..\src\engine.h:25,
from ..\src\position_evaluate_pawn.cxx:25:
..\src\hash.h: At global scope:
..\src\hash.h:118: error: `Uint32' does not name a type
..\src\hash.h:119: error: `Uint32' does not name a type
..\src\hash.h: In member function `void HashTable::Entry::packData1(const Move&, unsigned int, unsigned int)':
..\src\hash.h:71: error: `data1' was not declared in this scope
..\src\hash.h:71: warning: unused variable 'data1'
..\src\hash.h: In member function `void HashTable::Entry::packData2(int, int)':
..\src\hash.h:75: error: `data2' was not declared in this scope
..\src\hash.h:75: warning: unused variable 'data2'
..\src\hash.h: In member function `unsigned int HashTable::Entry::isUpperBound() const':
..\src\hash.h:84: error: `data1' was not declared in this scope
..\src\hash.h:84: warning: unused variable 'data1'
..\src\hash.h: In member function `unsigned int HashTable::Entry::hasSingleReply() const':
..\src\hash.h:88: error: `data1' was not declared in this scope
..\src\hash.h:88: warning: unused variable 'data1'
..\src\hash.h: In member function `unsigned int HashTable::Entry::hasMateThreat() const':
..\src\hash.h:92: error: `data1' was not declared in this scope
..\src\hash.h:92: warning: unused variable 'data1'
..\src\hash.h: In member function `int HashTable::Entry::getValue() const':
..\src\hash.h:96: error: `data2' was not declared in this scope
..\src\hash.h:96: warning: unused variable 'data2'
..\src\hash.h: In member function `int HashTable::Entry::getDepth() const':
..\src\hash.h:100: error: `data2' was not declared in this scope
..\src\hash.h:100: warning: unused variable 'data2'
..\src\hash.h: In member function `int HashTable::Entry::getBound() const':
..\src\hash.h:105: error: `data1' was not declared in this scope
..\src\hash.h:105: warning: unused variable 'data1'
..\src\hash.h: In member function `unsigned int HashTable::Entry::getSearchId() const':
..\src\hash.h:109: error: `data1' was not declared in this scope
..\src\hash.h:109: warning: unused variable 'data1'
..\src\hash.h: In member function `Move HashTable::Entry::getMove() const':
..\src\hash.h:113: error: `data1' was not declared in this scope
..\src\hash.h:113: warning: unused variable 'data1'
..\src\hash.h: At global scope:
..\src\hash.h:176: error: `Uint32' does not name a type
In file included from ..\src\engine.h:28,
from ..\src\position_evaluate_pawn.cxx:25:
..\src\pawnhash.h:95: error: `Uint32' does not name a type
..\src\pawnhash.h:96: error: `Uint32' does not name a type
..\src\pawnhash.h:97: error: `Uint32' does not name a type
..\src\pawnhash.h:98: error: `Uint32' does not name a type
..\src\pawnhash.h: In member function `void PawnHashEntry::setFlags1(unsigned int)':
..\src\pawnhash.h:71: error: `flags1' was not declared in this scope
..\src\pawnhash.h:71: warning: unused variable 'flags1'
..\src\pawnhash.h: In member function `void PawnHashEntry::setFlags2(unsigned int)':
..\src\pawnhash.h:75: error: `flags2' was not declared in this scope
..\src\pawnhash.h:75: warning: unused variable 'flags2'
..\src\pawnhash.h: In member function `void PawnHashEntry::setBlackScore(int, int)':
..\src\pawnhash.h:79: error: `blackScore' was not declared in this scope
..\src\pawnhash.h:79: warning: unused variable 'blackScore'
..\src\pawnhash.h: In member function `void PawnHashEntry::setWhiteScore(int, int)':
..\src\pawnhash.h:83: error: `whiteScore' was not declared in this scope
..\src\pawnhash.h:83: warning: unused variable 'whiteScore'
..\src\pawnhash.h: In member function `void PawnHashEntry::reset()':
..\src\pawnhash.h:87: error: `flags2' was not declared in this scope
..\src\pawnhash.h:87: warning: unused variable 'flags2'
..\src\pawnhash.h: In member function `unsigned int PawnHashEntry::isValid() const':
..\src\pawnhash.h:92: error: `flags2' was not declared in this scope
..\src\pawnhash.h:92: warning: unused variable 'flags2'
..\src\position_evaluate_pawn.cxx: In member function `PawnHashEntry* Position::evaluatePawnStructure() const':
..\src\position_evaluate_pawn.cxx:169: warning: unused variable 'f'
..\src\position_evaluate_pawn.cxx:148: warning: unused variable 'zmax'
..\src\position_evaluate_pawn.cxx:149: warning: unused variable 'zmin'
..\src\position_evaluate_pawn.cxx:260: warning: unused variable 'zmax'
..\src\position_evaluate_pawn.cxx:261: warning: unused variable 'zmin'
..\src\position_evaluate_pawn.cxx: At global scope:
..\src\position_evaluate_pawn.cxx:41: warning: 'char* sqname(int)' defined but not used
Build error occurred, build is stopped
Time consumed: 965 ms.
This is the content of platform.h where the define statements are:
#ifndef PLATFORM_H_
#define PLATFORM_H_
#if defined(_MSC_VER)
#define CDECL __cdecl
#define CACHE_ALIGN __declspec(align(64))
#else
#define CDECL
#define CACHE_ALIGN
#endif
#if defined(LINUX_I386) || defined(WIN_I386) || defined(MAC_G4)
// 32-bit platform
#if defined(__GNUC__)
typedef unsigned long long Uint64;
typedef unsigned Uint32;
#ifndef PRIx64
#define PRIx64 "llx"
#endif
#define MK_U64( n ) n##ull
#else // Visual C++
typedef unsigned __int64 Uint64;
typedef unsigned Uint32;
#ifndef PRIx64
#define PRIx64 "I64x"
#endif
#define MK_U64( n ) n
#endif
#endif // 32 or 64 bit platform
#endif // PLATFORM_H_
and one of the files, bitboard.h where the errors appear:
#ifndef BITBOARD_H_
#define BITBOARD_H_
// Note: assembly code removed in version 0.6d
#include <stdio.h>
#include "platform.h"
extern CACHE_ALIGN const unsigned int lsz64_tbl[64];
/*
Bit count function by Gerd Isenberg.
*/
inline int bitCount( Uint64 bb )
{
unsigned w = (unsigned) (bb >> 32);
unsigned v = (unsigned) bb;
v = v - ((v >> 1) & 0x55555555);
w = w - ((w >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
v = (v + (v >> 4)) & 0x0F0F0F0F;
w = (w + (w >> 4)) & 0x0F0F0F0F;
v = ((v+w) * 0x01010101) >> 24;
return v;
}
/**
Bitboard, i.e. a 64-bit unsigned integer with some extra chess-related functions.
*/
class BitBoard
{
public:
static const BitBoard Clr[64];
static const BitBoard Set[64];
//
BitBoard() {
}
BitBoard( Uint32 lo, Uint32 hi ) {
data = ((Uint64)hi << 32) | ((Uint64)lo);
}
BitBoard( Uint64 n ) {
data = n;
}
BitBoard( const BitBoard & bb ) {
data = bb.data;
}
//
~BitBoard() {
}
//
void operator = ( const BitBoard & bb ) {
data = bb.data;
}
void operator = ( Uint64 bb ) {
data = bb;
}
//
void operator &= ( const BitBoard & bb ) {
data &= bb.data;
}
void operator |= ( const BitBoard & bb ) {
data |= bb.data;
}
void operator ^= ( const BitBoard & bb ) {
data ^= bb.data;
}
//
void operator &= ( Uint64 bb ) {
data &= bb;
}
void operator |= ( Uint64 bb ) {
data |= bb;
}
void operator ^= ( Uint64 bb ) {
data ^= bb;
}
BitBoard operator << ( int len ) const {
return BitBoard( data << len );
}
BitBoard operator >> ( int len ) const {
return BitBoard( data >> len );
}
//
BitBoard operator ~ () const {
return BitBoard( ~data );
}
BitBoard operator & ( const BitBoard & bb ) const {
return BitBoard( data & bb.data );
}
BitBoard operator | ( const BitBoard & bb ) const {
return BitBoard( data | bb.data );
}
BitBoard operator ^ ( const BitBoard & bb ) const {
return BitBoard( data ^ bb.data );
}
int operator < ( const BitBoard & bb ) const {
return data < bb.data;
}
int operator > ( const BitBoard & bb ) const {
return data > bb.data;
}
//
int operator == ( const BitBoard & bb ) const {
return data == bb.data;
}
int operator != ( const BitBoard & bb ) const {
return data != bb.data;
}
//
operator int () const {
return data != 0;
}
//
void setBit( unsigned idx ) {
data |= Set[idx].data;
}
void clrBit( unsigned idx ) {
data &= Clr[idx].data;
}
//
int getBit( unsigned idx ) const {
return (data & Set[idx].data) != 0 ? 1 : 0;
}
//
void clear( void ) {
data = 0;
}
void negate( void ) {
data = ~data;
}
void andNot( const BitBoard & bb ) {
data &= ~bb.data;
}
//
unsigned getRank( int rank ) const {
return 0xFF & (unsigned)(data >> (rank*8));
}
//
int isEmpty() const {
return (data == 0);
}
//
unsigned toByte( void ) const {
return (unsigned)data & 0xFF;
}
//
unsigned toUnsigned( void ) const {
return (unsigned)data;
}
// Dumps this bitboard to the logfile
void dump( const char * header = 0 ) const;
bool isZero() const {
return data == 0;
}
bool isNotZero() const {
return data != 0;
}
int bitScanForward() const;
public:
Uint64 data;
};
/*
Bit search functions by Gerd Isenberg.
*/
inline unsigned int bitSearch( BitBoard bb )
{
Uint64 b = bb.data ^ (bb.data - 1);
unsigned int fold = ((unsigned)b) ^ ((unsigned)(b>>32));
return lsz64_tbl[(fold * 0x78291ACF) >> (32-6)];
}
inline unsigned int bitSearchAndReset( BitBoard & bb )
{
Uint64 b = bb.data ^ (bb.data - 1);
bb.data = bb.data & (bb.data - 1);
unsigned int fold = ((unsigned)b) ^ ((unsigned)(b>>32));
return lsz64_tbl[(fold * 0x78291ACF) >> (32-6)];
}
inline int bitScanForward( BitBoard bb )
{
return bb.data != 0 ? bitSearch(bb) : -1;
}
inline int bitScanAndResetForward( BitBoard & bb )
{
return bb.data != 0 ? bitSearchAndReset(bb) : -1;
}
inline int bitCount( const BitBoard & b )
{
return bitCount( b.data );
}
inline int BitBoard::bitScanForward() const {
return ::bitScanForward( data );
}
#endif // BITBOARD_H_
You need Uint64
and Uint32
defined for your platform (you don't mention what that is in your question).
To do this you need to look at platform.h
, in the included source.
It looks like you are using some version of GCC on some version of Windows, so I suspect all you need to do is provide -DWIN_I386
to g++
. I don't know how to do that with your build environment. Were you using the supplied Makefile
, you'd take the following line...
CC_FLAGS = -Wall -DEOF_AS_INPUT -DGCC -DLINUX_I386 -O2
...and replace LINUX
with WIN
.
You'll find with that fixed, you have a more manageable list of warnings and errors. sehe's answer fixes one of the errors I encountered building with i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
. Here is a patch showing fixes for my build.
Once you have fixed the code for your platform, you should send a patch to Alessandro Scotti.
Enjoy!