I've been trying to compile the CPW-engine in VS 2019. I've cleaned up a lot of error messages about deprecated functions and pointer types, but I have one error left that I can't figure out:
in the input() function (com.cpp), it has the following line:
if (stdin->_cnt > 0) return 1;
This gives the errors:
Severity Code Description Project File Line Suppression State
Error C2039 '_cnt': is not a member of '_iobuf' CPW C:\games\chess\engine\CPW\code\com.cpp 50
Error (active) E0135 class "_iobuf" has no member "_cnt" CPW C:\games\chess\engine\CPW\code\com.cpp 50
Any ideas?
Compile CPW-Engine
Moderator: Ras
-
- Posts: 563
- Joined: Sat Mar 25, 2006 8:27 pm
- Location: USA
- Full name: Robert Pope
-
- Posts: 1632
- Joined: Thu Jul 16, 2009 10:47 am
- Location: Almere, The Netherlands
Re: Compile CPW-Engine
Since VS2015 _cnt does not exist anymore in the _iobuf struct, Microsoft moved to what they call the Universal CRT.
https://learn.microsoft.com/en-us/cpp/p ... w=msvc-140
In my engine I use _kbhit() to check whether there is input from the console, but you first have to determine if the engine is connected via a pipe or not.
I use this:
https://learn.microsoft.com/en-us/cpp/p ... w=msvc-140
In my engine I use _kbhit() to check whether there is input from the console, but you first have to determine if the engine is connected via a pipe or not.
I use this:
Code: Select all
// stdio
HANDLE hStdin;
HANDLE hStdout;
bool bPipe;
void InitIO()
{
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
bPipe = (GetFileType(hStdin) == FILE_TYPE_PIPE);
if (bPipe)
{
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
}
fflush(NULL);
}
bool CheckInput()
{
if (bPipe)
{ // anonymous pipe
DWORD dwAvail = 0;
if (PeekNamedPipe(hStdin, NULL, 0, NULL, &dwAvail, NULL) && dwAvail > 0) return true;
}
// console
else if (_kbhit()) return true;
return false;
}
-
- Posts: 563
- Joined: Sat Mar 25, 2006 8:27 pm
- Location: USA
- Full name: Robert Pope
Re: Compile CPW-Engine
Thanks, that's very helpful.