Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: What a difference...

Author: Russell Reagan

Date: 11:21:33 01/23/02

Go up one level in this thread


On January 23, 2002 at 03:54:31, Daniel Clausen wrote:

>Hi
>
>On January 22, 2002 at 21:07:57, Russell Reagan wrote:
>
>>I'm just analyzing a few loops and originally I was using C++ and iostream's
>>cout for displaying the result. I wondered if compiling the same thing in C and
>>using printf would make any difference...it did. Before I could hardly read the
>>ASM because it was strung out with all kinds of garbage. The ASM/source file
>>generated using C was 2K, the C++ one was 440K. Go figure, all for this:
>>
>>#include <stdio.h>
>>
>>void main() {
>>
>>	char squares[64];
>>	int i;
>>	int found = 0;
>>
>>	for(i = 0; i < 64; i++) {
>>
>>		if(squares[i] == 1)
>>			found = 1;
>>
>>	}
>>
>>	printf("%d",found);
>>
>>}
>>
>>You think there might be a little hidden overhead in C++?!
>>
>>Russell
>
>While it's obvious that this is not the complete program, please note that
>main() is supposed to return an int as opposed to nothing - at least according
>to the ANSI C standard.

Actually this is the entire program. I was just looking at what goes on in a
simple loop like this, and then seeing how it differed from using different
board representations like a 16x16 array or 0x88, bitboards, etc. I'm just
looking at small differences in simple loops.

Regarding ANSI C/C++...

If there were a single compiler that was 100% compliant then it would make sense
to program according to it, but seeing as there are no compilers that are 100%
ANSI C/C++ compliant, it's just a matter of whatever works IMO.

>
>Sargon



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.