Author: milix
Date: 05:05:08 06/23/04
Go up one level in this thread
If you want to have a source file that compiles in Windows and Linux without
modification, you will need to use #ifdefs. Some common checks you may need are:
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
// for compatibility
#ifndef O_BINARY
#define O_BINARY 0
#endif
I use write() and read() for file (and user input) I/O. If you use fread/fwrite
this is not needed.
clock_t Engine::time_ms()
{
#if defined(__linux__)
timeval tv;
gettimeofday(&tv, NULL);
return (clock_t)(tv.tv_sec*1000 + tv.tv_usec/1000);
#else
return clock();
#endif
}
to get current time in miliseconds. Note that for GCC 3.X for windows clock()
returns miliseconds already, thus the ifdef __linux__.
#ifdef __linux__
printf("HASH SIGNATURE [%llX]\n", h64);
#else
printf("HASH SIGNATURE [%I64X]\n", h64);
#endif
to output an 64 bit value. with %I64X I had problems (crash) with Intel Compiler
7 for Linux (somebody else to confirm this?).
And a GCC specific if you use bitboards:
typedef unsigned long long bitboard
instead of unsigned __int64 bitboard (Intel Compiler for Linux works ok with
this)
--
Anastasios Milikas
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.