Hallo,
if I have a file smaug.cpp with the following content
-----------------------
#include "benchmark.cpp"
.
.
.
#include "tt.cpp"
#include "value.cpp"
-----------------------
I get an error message:
>>> g++ -DNDEBUG -Wall -g -c smaug.cpp -o smaug.o
In file included from smaug.cpp:14:
bitboard.cpp: In function 'void<unnamed>::init_ray_bitboards()':
bitboard.cpp:402: warning: suggest parentheses around + or - in operand of &
In file included from smaug.cpp:34:
tt.cpp: In member function 'int TranspositionTable::full()':
tt.cpp:188: error: expected unqualified-id before numeric constant
However, if the file looks like
-----------------------
#include "tt.cpp"
#include "benchmark.cpp"
.
.
.
#include "value.cpp"
-----------------------
everything compiles fine.
Why?
Kind regards
Bernhard
Compiling glaurung, stockfish, smaug
Moderators: hgm, Rebel, chrisw
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Compiling glaurung, stockfish, smaug
Could you please post the line 188 of tt.cpp (where the error is) ?
I cannot access the sources now.
Another thing, are you sure the include directives refer to the source files and not to header.
IOW, are you sure is
include "tt.cpp"
or is
include "tt.h"
Thanks
Marco
I cannot access the sources now.
Another thing, are you sure the include directives refer to the source files and not to header.
IOW, are you sure is
include "tt.cpp"
or is
include "tt.h"
Thanks
Marco
-
- Posts: 658
- Joined: Wed Mar 08, 2006 8:58 pm
Re: Compiling glaurung, stockfish, smaug
This is line 188:
double N = double(size) * 4.0;
This is smaug.cpp
#include "benchmark.cpp"
#include "bitbase.cpp"
#include "bitboard.cpp"
#include "book.cpp"
#include "color.cpp"
#include "direction.cpp"
#include "endgame.cpp"
#include "evaluate.cpp"
#include "history.cpp"
#include "main.cpp"
#include "material.cpp"
#include "mersenne.cpp"
#include "misc.cpp"
#include "move.cpp"
#include "movegen.cpp"
#include "movepick.cpp"
#include "pawns.cpp"
#include "piece.cpp"
#include "position.cpp"
#include "san.cpp"
#include "search.cpp"
#include "square.cpp"
#include "tt.cpp"
#include "uci.cpp"
#include "ucioption.cpp"
#include "value.cpp"
Here I do the same as in crafty.
Kind regards
Bernhard
double N = double(size) * 4.0;
This is smaug.cpp
#include "benchmark.cpp"
#include "bitbase.cpp"
#include "bitboard.cpp"
#include "book.cpp"
#include "color.cpp"
#include "direction.cpp"
#include "endgame.cpp"
#include "evaluate.cpp"
#include "history.cpp"
#include "main.cpp"
#include "material.cpp"
#include "mersenne.cpp"
#include "misc.cpp"
#include "move.cpp"
#include "movegen.cpp"
#include "movepick.cpp"
#include "pawns.cpp"
#include "piece.cpp"
#include "position.cpp"
#include "san.cpp"
#include "search.cpp"
#include "square.cpp"
#include "tt.cpp"
#include "uci.cpp"
#include "ucioption.cpp"
#include "value.cpp"
Here I do the same as in crafty.
Kind regards
Bernhard
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Compiling glaurung, stockfish, smaug
Ok, now I have downloaded smaug sources from http://kiiski.info/smaug/ ...but I cannot see the smaug.cpp file.
Is it a file from smaug distribuition or have you added it yourself ?
In the second case I would argue that the subject of the topic is incorrect.
Thanks
Marco
Is it a file from smaug distribuition or have you added it yourself ?
In the second case I would argue that the subject of the topic is incorrect.
Thanks
Marco
-
- Posts: 658
- Joined: Wed Mar 08, 2006 8:58 pm
Re: Compiling glaurung, stockfish, smaug
The problem occurs when compiling "glaurung, stockfish, smaug",
therefor the subject.
I have only put the source files into one file called glaurung.cpp, stockfish.cpp or
smaug.cpp.
This is what the intel compiler says
tt.cpp(188): error: expected an identifier
double N = double(size) * 4.0;
^
compilation aborted for smaug.cpp (code 2)
Compiling tt.cpp gives no error.
Kind regards
Bernhard
therefor the subject.
I have only put the source files into one file called glaurung.cpp, stockfish.cpp or
smaug.cpp.
This is what the intel compiler says
tt.cpp(188): error: expected an identifier
double N = double(size) * 4.0;
^
compilation aborted for smaug.cpp (code 2)
Compiling tt.cpp gives no error.
Kind regards
Bernhard
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Compiling glaurung, stockfish, smaug
The problem is in the previous line, please post some lines before the 188.
I really don't understund the meaning of that <engine_name>.cpp file with all that includes of *.cpp...anyway...the point is...I also don't want to understand
Thanks
Marco
I really don't understund the meaning of that <engine_name>.cpp file with all that includes of *.cpp...anyway...the point is...I also don't want to understand
Thanks
Marco
-
- Posts: 1808
- Joined: Wed Mar 08, 2006 9:19 pm
- Location: Oslo, Norway
Re: Compiling glaurung, stockfish, smaug
I think it's an ugly "optimization" some people use as a workaround for compilers which are not able to inline function calls across file boundaries. Of course it isn't guaranteed to work, because identifier names in different modules may clash. I suspect that this is the reason for Bernhard's problem, but I also don't have the source code available right now, so I can't check.mcostalba wrote:The problem is in the previous line, please post some lines before the 188.
I really don't understund the meaning of that <engine_name>.cpp file with all that includes of *.cpp...anyway...the point is...I also don't want to understand
Tord
-
- Posts: 1922
- Joined: Thu Mar 09, 2006 12:51 am
- Location: Earth
Re: Compiling glaurung, stockfish, smaug
While I agree that it's ugly, I have been able to get pretty good results with it. I usually get 10-20% IIRC using GCC.Tord Romstad wrote:I think it's an ugly "optimization" some people use as a workaround for compilers which are not able to inline function calls across file boundaries. Of course it isn't guaranteed to work, because identifier names in different modules may clash. I suspect that this is the reason for Bernhard's problem, but I also don't have the source code available right now, so I can't check.mcostalba wrote:The problem is in the previous line, please post some lines before the 188.
I really don't understund the meaning of that <engine_name>.cpp file with all that includes of *.cpp...anyway...the point is...I also don't want to understand
Tord
-
- Posts: 658
- Joined: Wed Mar 08, 2006 8:58 pm
Re: Compiling glaurung, stockfish, smaug
Yes, variable N is defined in mersenne.cpp.
If mersenne.cpp comes before tt.cpp compilers will show an error.
It hurts probably nothing.
kind regards
Bernhard
If mersenne.cpp comes before tt.cpp compilers will show an error.
It hurts probably nothing.
kind regards
Bernhard
-
- Posts: 1808
- Joined: Wed Mar 08, 2006 9:19 pm
- Location: Oslo, Norway
Re: Compiling glaurung, stockfish, smaug
Yes, I think GCC (at least until version 4.2) is one of those compilers which can't inline function calls across module boundaries.Zach Wegner wrote:While I agree that it's ugly, I have been able to get pretty good results with it. I usually get 10-20% IIRC using GCC.
My way of thinking about this kind of problems is that the 10-20% performance penalty (of course the numbers could be different for my program, but I'm too lazy to test) is a weakness of GCC, and not of my program. It's therefore the GCC developers' responsibility to fix it, and not mine, and I'm not willing to do any strange hacks to work around it.
Tord