Crafty 25.3 MSVS 2019

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Graham Banks
Posts: 41415
Joined: Sun Feb 26, 2006 10:52 am
Location: Auckland, NZ

Re: Crafty 25.3 MSVS 2019

Post by Graham Banks »

jhaglund2 wrote: Mon Sep 09, 2019 7:44 pm Update: It compiles the same, without TB.

Crafty 25.3 - VS 2019 source http://www.filedropper.com/crafty-253-vs2019

Crafty 25.3 - 64 CPU
crafty.zip
Thanks for your help. Is this the exe I should use, rather than the previous one you posted.
gbanksnz at gmail.com
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 25.3 MSVS 2019

Post by bob »

OK, a few notes.

(1) the stdatomic.h error requires the definition of _cplusplus which I assume is a windows thing. Note that this changed since I went to the new syzygy support code that Ronald pointed me to. If that is defined, then it includes atomic.h which I assume (again) is a windows thing... This means that using a c++ compile will likely work for that file (tbprobe.c I think). Or you can find out what the standard C compiler defines as an identifying string and replace the cplussplus with that string.

(2) many of the other errors seem to be around the RESTRICT password which was something Eugene Nalimov added to Crafty years ago. For all of the other errors (option.c, book.c and such) they were not changed from 25.2 to 25.3, so something changed in windows C compiler (big surprise there). If someone is interested in pursuing these, let me know. I have cleaned up the formats issues, and removed all the RESTRICTs everywhere. Still compiles clean on my gcc box and using clang on my MacBook... If you are interested, I can zip and email you the complete source and we can try a few compile cycles to see if these can be cleaned up for windows. (this is one reason I despise microsoft).

BTW I believe those errors in option.c spin around using size_t and uint64_t in different places. Think I have fixed that as this really is a 64 bit only program anyway so size_t is not really needed and seems to aggravate MSVC as being different from uint64_t (which are both supposed to resolve to the same thing size-wise.)
jhaglund2
Posts: 65
Joined: Mon Jan 16, 2017 6:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 »

Thanks for your help. Is this the exe I should use, rather than the previous one you posted.
Doesn't really matter. A better one will be done soon. ;)
jhaglund2
Posts: 65
Joined: Mon Jan 16, 2017 6:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 »

bob wrote: Tue Sep 10, 2019 6:08 am OK, a few notes.

(1) the stdatomic.h error requires the definition of _cplusplus which I assume is a windows thing. Note that this changed since I went to the new syzygy support code that Ronald pointed me to. If that is defined, then it includes atomic.h which I assume (again) is a windows thing... This means that using a c++ compile will likely work for that file (tbprobe.c I think). Or you can find out what the standard C compiler defines as an identifying string and replace the cplussplus with that string.
I took a look at tbprobe.c, and that looks fine, so I downloaded some of those include files that didn't come with VS2019, and put them in my library folder. https://github.com/zenny-chen/simple-st ... r-VS-Clang

Code: Select all

#ifdef __cplusplus
#include <atomic>
#else
#include <stdatomic.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef uint8_t bool;  //illegal
#include "tbprobe.h"

#ifdef __cplusplus
using namespace std;
#endif
1 error and multiple warnings.

tbprobe.c(34): error C2628: 'uint8_t' followed by 'bool' is illegal (did you forget a ';'?)

changed to:

Code: Select all

typedef uint8_t; bool; // correct?


Notable warnings...

thread.c(455): warning C4028: formal parameter 1 different from declaration
thread.c(888): warning C4028: formal parameter 1 different from declaration
tbprobe.c(180): warning C4005: 'max': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\stdlib.h(1289): note: see previous definition of 'max'
tbprobe.c(181): warning C4005: 'min': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\stdlib.h(1290): note: see previous definition of 'min'
tbprobe.c(484): warning C4028: formal parameter 10 different from declaration
tbprobe.c(529): warning C4028: formal parameter 11 different from declaration
tbprobe.c(579): warning C4028: formal parameter 12 different from declaration
tbprobe.c(579): warning C4028: formal parameter 13 different from declaration
tbprobe.c(579): warning C4028: formal parameter 14 different from declaration
tbprobe.c(612): warning C4028: formal parameter 12 different from declaration
tbprobe.c(612): warning C4028: formal parameter 13 different from declaration
tbprobe.c(795): warning C4142: 'tb_init': benign redefinition of type
tbprobe.h(155): note: see declaration of 'tb_init'
tbprobe.c(2617): warning C4028: formal parameter 2 different from declaration

(2) many of the other errors seem to be around the RESTRICT password which was something Eugene Nalimov added to Crafty years ago. For all of the other errors (option.c, book.c and such) they were not changed from 25.2 to 25.3, so something changed in windows C compiler (big surprise there). If someone is interested in pursuing these, let me know. I have cleaned up the formats issues, and removed all the RESTRICTs everywhere. Still compiles clean on my gcc box and using clang on my MacBook... If you are interested, I can zip and email you the complete source and we can try a few compile cycles to see if these can be cleaned up for windows. (this is one reason I despise microsoft).
This sounds good. The real problem was the transition from 25.0.1 to 25.2, replacing the EGTB.
Indeed, I am always interested.
BTW I believe those errors in option.c spin around using size_t and uint64_t in different places. Think I have fixed that as this really is a 64 bit only program anyway so size_t is not really needed and seems to aggravate MSVC as being different from uint64_t (which are both supposed to resolve to the same thing size-wise.)
Also a good plan.
That said, I re-enabled tbprobe.c in crafty.c, and added /DSYZYGY to Makefile.xp
It compiles after that 1 change, with those warnings above, & pending anything from the incoming changes you've made.

White(1): egtb
SYZYGY EGTB access enabled, 3 piece TBs found

It appears to be working.

Ready to test what you have.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 25.3 MSVS 2019

Post by bob »

It looks like that typedef is backward. IE typedef bool uint8_t; was probably intended. No idea since I didn't write that code...

let me know how you want me to send the source and I'll send you a .zip to try...
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Crafty 25.3 MSVS 2019

Post by Dann Corbit »

Since it is C and not C++, this should be OK:
typedef uint8_t bool; //illegal
And since it follows:
#include <stdint.h>
there should be no problem with a missing definition for uint8_t
See:
https://en.wikibooks.org/wiki/C_Programming/stdint.h

I think the compiler was broken or there is another header with something strange in it.

That typedef is obviously intended to make a type called bool that has an unsigned byte as its underlying type.

The other possibility is that a C++ compiler was invoked on the file, and not a C compiler, because bool is already defined in C++.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
jhaglund2
Posts: 65
Joined: Mon Jan 16, 2017 6:28 pm

Re: Crafty 25.3 MSVS 2019

Post by jhaglund2 »

bob wrote: Tue Sep 10, 2019 11:48 pm It looks like that typedef is backward. IE typedef bool uint8_t; was probably intended. No idea since I didn't write that code...

let me know how you want me to send the source and I'll send you a .zip to try...

Code: Select all

typedef bool uint8_t; //corrected;
I sent you a PM with info.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Crafty 25.3 MSVS 2019

Post by jdart »

Dann Corbit wrote: Wed Sep 11, 2019 1:49 am bool is already defined in C++.
Only in C++-17, as std::bool. As I mentioned earlier, tbprobe.c is intended to be compiled either as C99 or C++. Either should work, although I have not tested C++17. I have compiled it with MSVC 2019 (C++) and it worked.

--Jon
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 25.3 MSVS 2019

Post by bob »

while Joshua and I try to get 25.3 cleaned up for windows, here is a windows question.

In gcc (linux / macos) or clang (macOS) we have three bit manipulation intrinsics:

# define PopCnt(v) __builtin_popcountll(v)
# define LSB(v) __builtin_ctzll(v)
# define MSB(v) (63 - __builtin_clzll(v))

For windows I think I have found two of the three:

# define PopCnt(v) __lzcnt64(v)
# define LSB(v) <unknown so far>
# define MSB(v) (63 - __lzcnt64(v))

Any pointers here???
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Crafty 25.3 MSVS 2019

Post by jdart »

For MSVC (_MSC_VER defined) you want:

_BitScanForward64, _BitScanReverse64 for LSB, MSB:

https://docs.microsoft.com/en-us/cpp/in ... ew=vs-2019