The full error is
1>d:\test\src\search.cpp(130): error C2371: 'Pos' : redefinition; different basic types
1> d:\test\src\search.cpp(100) : see declaration of 'Pos'
- search.cpp, line 130:
Moves(*Pos);(If I omit this line, the code compiles without error.) - search.cpp, line 100:
Position *Pos = Mov.ChildPosition;
The Moves constructor is declared: Moves(Position &Pos);
Mov is a function argument: void searchMove(Move &Mov)
Why does MSVC say I’m redefining Pos?
Update 1: As requested:
- main.cpp, line 32:
Position Pos(TESTF, TESTW, TESTB); - main.cpp, line 36:
searchRoot(Pos, 5); - moves.cpp, line 467:
Position *NextPosition = new Position(ParentPosition->flags^0x8000, white, black, theirs, ours); - moves.cpp, line 474:
Move *Mov = new Move(*NextPosition, piece, square1, square2, capture); - search.cpp, line 26:
void searchRoot(Position &Pos, U8 depth) - search.cpp, line 32:
Moves Mov(Pos);
Position objects are passed to the constructors of Move and Moves objects, stored in ChildPosition and ParentPosition respectively.
Update 2: I replaced line 130 with David Norman’s suggestion below, and now I’m receiving five “LNK2001: unresolved external symbol” errors. This is strange because they all refer to variables declared using extern in my search.h file.
Update 3: I replaced extern with static and everything now compiles. I don’t understand why I was getting the errors I was. Can anyone explain this to me?
If your intention is to create a Moves object on line 130, then try giving it a name:
Otherwise you are probably declaring a variable named Pos of type Moves *