Reputation: 469
Everything was compiling until I added vector<Move> bestLine;
search.h
#ifndef SEARCH_H
#define SEARCH_H
#include <vector>
#include "types.h"
#include "position.h"
#include "move.h"
#include "moves.h"
U8 searchDepth;
U8 searchCount;
vector<Move> bestLine; // The compiler doesn't like this.
void searchPosition(Position &P, U8 depth);
void searchMove(Move &M);
#endif
The errors I'm receiving are:
1>d:\test\search.h(12): error C2143: syntax error : missing ';' before '<'
1>d:\test\search.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\test\search.cpp(30): error C2065: 'bestLine' : undeclared identifier
It seems that the compiler isn't recognizing Move
, so bestLine
isn't being declared. I thought it might be a circular dependency and tried declaring an incomplete type for Move
, but it had no effect. Can someone explain what I'm missing?
Upvotes: 0
Views: 6324
Reputation: 258618
Actually qualifying is not enough, although necessary:
std::vector<Move> bestLine;
This also constitutes a definition, and, if in a header, you risk having linker errors.
You should declare it extern
and define it in a single implementation file:
//search.h
//...
extern std::vector<Move> bestLine;
//search.cpp
//...
std::vector<Move> bestLine;
Upvotes: 7
Reputation: 4663
try adding the statement after the header file inclusion
using namespace std;
otherwise declare vector as
std::vector<Move>bestLine;
Upvotes: -3