Dieter B?r?ner wrote:Tord Romstad wrote:I appreciate your nit pickings. I have never really learned the C programming language, and as a consequence I program in a mixture of ANSI C, GNU-specific extensions, and Unix system calls, without really knowing what is what. When I wrote my code, I thought the strncasecmp function was part of the standard C library. Evidently I was wrong. I suppose I should add something like;
- Code: Select all
#if defined(UNIX)
# define str_casecmp strcasecmp
# define str_ncasecmp strncasecmp
#endif
to my header file, and at the same time change the names of the functions in Dann's strcase.c file.
Tord
Really, I am very pedantic
I guess, when you compile your code with strictest Standard C conformance flags, this still can have problems. Under these conditions the compiler may choose to hide strcasecmp from string.h. Also, of course, the compiler will not define UNIX then (I guess you are aware of this).
No, I was not aware of this at all. Thanks for telling me!
Anyway, this really is too much nit picking. I did not look at your code yet. When I looked at free code earlier, I was always a bit dissapointed. I am convinced, that it is possible to write a decent chess engine in pure Standard C, with the exception of very few routines (only timing code and input polling comes to my mind), that can be well seperated. In a learning engine, I think it would be nice to have Standard C. When I first looked at TSCP: it assumes 32 bit int, IIRC also some issues with signedness, etc. Things that are not guaranteed in Standard C (but of course will work under most environments nowadays, although at that time I still used old Borland C 3.5, under which TSCP would not work, and it would be quite some effort to make it work).
You would probably be disappointed by Glaurung, too. I am not the right person to write a decent engine in pure Standard C, for the simple reason that I do not know Standard C. As far as I know, I do not assume 32 bit ints or anything similar, but it would surprise me if you could not find some compiler and platform where my code does not work. It has only been tested on various Unix platforms.
If you ever decide to take a look at my source code (but frankly, I doubt that it would be worth the effort for an experienced programmer like you), I would of course be very happy to receive all the pedantic feedback you can give me.
BTW. For what do you need strcasecmp (in the context of UCI)? Aren't UCI commands case sensitive?
If I recall correctly (which I very possibly do not), this is not specified in the UCI protocol. I no longer remember clearly why I chose to use strcasecmp rather than strcmp, but I think I was afraid that different GUIs would use different case conventions. Case insensitivity also makes it easier to interact with the engine from the console while debugging.
Tord