building glaurung2.1 from empty code project
Posted: Sun Aug 31, 2008 11:48 am
My opinion is that the best way to understand chess program is simply trying to build them from scratch by copying minimal parts that you can compile and understand the parts that you copied and later adding more parts.
I decided in the past to start doing it with glaurung1.2.1 but stopped.
I decided to do it again with Glaurung2.1 and this time I plan to make everything that I do with Glaurung2.1 public.
Note that my knowledge about programming is limited so I may ask a lot of questions that seem to you stupid questions because of commands that I do not understand.
First step is simply generating new empty project with the name Glaurung_learn and adding the file main.cpp to it.
I copy to main.cpp the following code from Glaurung2.1
1)When I compile it I get warning C4995\6
'setbuf': This function or variable may be unsafe. Consider using setvbuf instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Does it mean that Glaurung is written wrongly or maybe I do not need to care about these warning or maybe there are not going to be warning with the full glaurung program.
Except this I have the following questions
2)I am used to use int main(void)
I read the following
"The argument argc is the number of command-line arguments passed to the program. The argument argv is a pointer to an array of strings, where argv[0] is the name you used to run your program from the command-line"
What is the meaning of this command line and can you give me step by step instruction how to run a program from the command line?
3)How can the computer understand setbuf?
When I click help on the word setbuf I find that stdio.h is required header but glaurung does not use stdio.h and it seems that <iostream> is enough to compile it.
4)I am not sure if I understand exactly what setbuf does except the fact that it does some cleaning to the standard input and standard output files.
I guess that the target is that the program will get correct information when it read later some input from the interface or from the user and will forget some information that the user gave before starting to run the program but I am not sure.
An example when things do not work and explanation why they do not work can be productive.
5)I do not understand what is the purpose of the next lines of std:: with rdbuf and pubsetbuf
I do not use these commands and it can be productive if somebody explain to me what they are doing.
Uri
I decided in the past to start doing it with glaurung1.2.1 but stopped.
I decided to do it again with Glaurung2.1 and this time I plan to make everything that I do with Glaurung2.1 public.
Note that my knowledge about programming is limited so I may ask a lot of questions that seem to you stupid questions because of commands that I do not understand.
First step is simply generating new empty project with the name Glaurung_learn and adding the file main.cpp to it.
I copy to main.cpp the following code from Glaurung2.1
Code: Select all
#include <iostream>
int main(int argc, char *argv[])
{
setbuf(stdin, NULL);
setbuf(stdout, NULL);
std::cout.rdbuf()->pubsetbuf(NULL, 0);
std::cin.rdbuf()->pubsetbuf(NULL, 0);
return 0;
}
'setbuf': This function or variable may be unsafe. Consider using setvbuf instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Does it mean that Glaurung is written wrongly or maybe I do not need to care about these warning or maybe there are not going to be warning with the full glaurung program.
Except this I have the following questions
2)I am used to use int main(void)
I read the following
"The argument argc is the number of command-line arguments passed to the program. The argument argv is a pointer to an array of strings, where argv[0] is the name you used to run your program from the command-line"
What is the meaning of this command line and can you give me step by step instruction how to run a program from the command line?
3)How can the computer understand setbuf?
When I click help on the word setbuf I find that stdio.h is required header but glaurung does not use stdio.h and it seems that <iostream> is enough to compile it.
4)I am not sure if I understand exactly what setbuf does except the fact that it does some cleaning to the standard input and standard output files.
I guess that the target is that the program will get correct information when it read later some input from the interface or from the user and will forget some information that the user gave before starting to run the program but I am not sure.
An example when things do not work and explanation why they do not work can be productive.
5)I do not understand what is the purpose of the next lines of std:: with rdbuf and pubsetbuf
I do not use these commands and it can be productive if somebody explain to me what they are doing.
Uri